ZQuest Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2024-05-10 00:25:22
Exec Total Coverage
Lines: 1996 4413 45.2%
Functions: 137 331 41.4%
Branches: 1322 3590 36.8%

Line Branch Exec Source
1 #include "zc/zc_sys.h"
2
3 #include "allegro/gfx.h"
4 #include "allegro5/joystick.h"
5 #include "base/render.h"
6 #include "zalleg/zalleg.h"
7 #include "base/qrs.h"
8 #include "base/dmap.h"
9 #include <functional>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <cstring>
13 #include <math.h>
14 #include <map>
15 #include <filesystem>
16 #include <ctype.h>
17 #include <sstream>
18 #include "base/version.h"
19 #include "base/zc_alleg.h"
20 #include "gamedata.h"
21 #include "zc/zc_init.h"
22 #include "init.h"
23 #include "zc/replay.h"
24 #include "zc/cheats.h"
25 #include "zc/render.h"
26 #include "base/zc_math.h"
27 #include "base/zapp.h"
28 #include "dialog/cheatkeys.h"
29 #include "metadata/metadata.h"
30 #include "zc/zelda.h"
31 #include "zc/saves.h"
32 #include "tiles.h"
33 #include "base/colors.h"
34 #include "pal.h"
35 #include "base/zsys.h"
36 #include "qst.h"
37 #include "zc/zc_sys.h"
38 #include "play_midi.h"
39 #include "gui/jwin_a5.h"
40 #include "base/jwinfsel.h"
41 #include "base/gui.h"
42 #include "midi.h"
43 #include "subscr.h"
44 #include "zc/maps.h"
45 #include "sprite.h"
46 #include "zc/guys.h"
47 #include "zc/hero.h"
48 #include "zc/title.h"
49 #include "particles.h"
50 #include "sound/zcmusic.h"
51 #include "zconsole.h"
52 #include "zc/ffscript.h"
53 #include "dialog/info.h"
54 #include "dialog/alert.h"
55 #include "zc/combos.h"
56 #include "zc/jit.h"
57 #include "zc/zc_subscr.h"
58 #include <fmt/format.h>
59 #include "zinfo.h"
60 #include "base/misctypes.h"
61 #include "music_playback.h"
62 #include <base/new_menu.h>
63
64 #ifdef __EMSCRIPTEN__
65 #include "base/emscripten_utils.h"
66 #endif
67
68 using namespace std::chrono_literals;
69
70 extern FFScript FFCore;
71 extern bool Playing;
72 int32_t sfx_voice[WAV_COUNT];
73 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
74 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
75
76 static ALLEGRO_JOYSTICK* gamepad_dlg_cur_joystick;
77 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c);
78
79 extern byte monochrome_console;
80
81 extern HeroClass Hero;
82 extern zcmodule moduledata;
83 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
84 extern particle_list particles;
85 extern int32_t loadlast;
86 extern char *sfx_string[WAV_COUNT];
87 byte use_dwm_flush;
88 byte use_save_indicator;
89 int32_t paused_midi_pos = 0;
90 byte midi_suspended = 0;
91 byte zc_192b163_warp_compatibility;
92 char modulepath[2048];
93 bool epilepsyFlashReduction;
94 signed char pause_in_background_menu_init = 0;
95 byte pause_in_background = 0;
96 bool is_sys_pal = false;
97 static bool load_control_called_this_frame;
98 extern PALETTE* hw_palette;
99 extern bool update_hw_pal;
100 extern const char* dmaplist(int32_t index, int32_t* list_size);
101 int32_t getnumber(const char *prompt,int32_t initialval);
102
103 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
104 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
105
106 static const char *qst_module_name = "current_module";
107 #ifdef ALLEGRO_LINUX
108 static const char *samplepath = "samplesoundset/patches.dat";
109 #endif
110 char qst_files_path[2048];
111
112 extern TopMenu the_player_menu;
113 #ifdef _MSC_VER
114 #define getcwd _getcwd
115 #endif
116
117 bool rF11();
118 bool rI();
119 bool rQ();
120 bool zc_key_pressed();
121
122 #ifdef _WIN32
123
124 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
125 extern "C"
126 {
127 typedef HRESULT(WINAPI *t_DwmFlush)();
128 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
129 }
130
131 void do_DwmFlush()
132 {
133 static HMODULE shell = LoadLibrary("dwmapi.dll");
134
135 if(!shell)
136 return;
137
138 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
139 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
140
141 BOOL enabled;
142 isEnabled(&enabled);
143
144 if(isEnabled)
145 flush();
146 }
147
148 #endif // _WIN32
149
150 92829 bool flash_reduction_enabled(bool check_qr)
151 {
152
4/4
✓ Branch 0 taken 88404 times.
✓ Branch 1 taken 4425 times.
✓ Branch 2 taken 87576 times.
✓ Branch 3 taken 92001 times.
92829 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
153 }
154
155 // Dialogue largening
156 void large_dialog(DIALOG *d)
157 {
158 large_dialog(d, 1.5);
159 }
160
161 void large_dialog(DIALOG *d, float RESIZE_AMT)
162 {
163 if(!d[0].d1)
164 {
165 d[0].d1 = 1;
166 int32_t oldwidth = d[0].w;
167 int32_t oldheight = d[0].h;
168 int32_t oldx = d[0].x;
169 int32_t oldy = d[0].y;
170 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
171 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
172 d[0].w = int32_t(d[0].w*RESIZE_AMT);
173 d[0].h = int32_t(d[0].h*RESIZE_AMT);
174
175 for(int32_t i=1; d[i].proc !=NULL; i++)
176 {
177 // Place elements horizontally
178 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
179 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
180
181 if(d[i].proc != d_stringloader)
182 {
183 if(d[i].proc==d_bitmap_proc)
184 {
185 d[i].w *= 2;
186 }
187 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
188 }
189
190 // Place elements vertically
191 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
192 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
193
194 // Vertically resize elements
195 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
196 {
197 d[i].h = int32_t((double)d[i].h*1.5);
198 }
199 else if(d[i].proc == jwin_droplist_proc || d[i].proc == d_joylist_proc)
200 {
201 d[i].y += int32_t((double)d[i].h*0.25);
202 d[i].h = int32_t((double)d[i].h*1.25);
203 }
204 else if(d[i].proc==d_bitmap_proc)
205 {
206 d[i].h *= 2;
207 }
208 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
209
210 // Fix frames
211 if(d[i].proc == jwin_frame_proc)
212 {
213 d[i].x++;
214 d[i].y++;
215 d[i].w-=4;
216 d[i].h-=4;
217 }
218 }
219 }
220
221 for(int32_t i=1; d[i].proc!=NULL; i++)
222 {
223 if(d[i].proc==jwin_slider_proc)
224 continue;
225
226 // Bigger font
227 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc && d[i].proc != d_joylist_proc);
228
229 if(!d[i].dp2 && bigfontproc)
230 {
231 d[i].dp2 = get_zc_font(font_lfont_l);
232 }
233 else if(!bigfontproc)
234 {
235 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
236 }
237
238 // Make checkboxes work
239 if(d[i].proc == jwin_check_proc)
240 d[i].proc = jwin_checkfont_proc;
241 else if(d[i].proc == jwin_radio_proc)
242 d[i].proc = jwin_radiofont_proc;
243 }
244
245 jwin_center_dialog(d);
246 }
247
248
249 /**********************************/
250 /******** System functions ********/
251 /**********************************/
252
253 static char cfg_sect[] = "zeldadx"; //We need to rename this.
254 static char ctrl_sect[] = "Controls";
255 static char sfx_sect[] = "Volume";
256
257 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
258 {
259 return D_O_K;
260 }
261
262 bool is_reserved_key(int c)
263 {
264 switch(c)
265 {
266 case KEY_ESC:
267 return true;
268 }
269 return false;
270 }
271 bool is_reserved_keycombo(int c, int modflag)
272 {
273 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
274 return true;
275 return false;
276 }
277 bool checkcheat(Cheat cheat)
278 {
279 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
280 return true; //Main key pressed
281 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
282 return true; //Alt key pressed
283 return false;
284 }
285 263 void load_default_cheatkeys()
286 {
287 263 memset(cheatkeys, 0, sizeof(cheatkeys));
288 263 cheatkeys[Cheat::Life][0] = KEY_H;
289 263 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
290 263 cheatkeys[Cheat::Magic][0] = KEY_M;
291 263 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
292 263 cheatkeys[Cheat::Rupies][0] = KEY_R;
293 263 cheatkeys[Cheat::Bombs][0] = KEY_B;
294 263 cheatkeys[Cheat::Arrows][0] = KEY_A;
295 263 cheatkeys[Cheat::Clock][0] = KEY_I;
296 263 cheatkeys[Cheat::Walls][0] = KEY_F11;
297 263 cheatkeys[Cheat::Fast][0] = KEY_Q;
298 263 cheatkeys[Cheat::Light][0] = KEY_L;
299 263 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
300 263 cheatkeys[Cheat::Kill][0] = KEY_K;
301 263 cheatkeys[Cheat::GoTo][0] = KEY_G;
302 263 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
303 263 cheatkeys[Cheat::ShowL0][0] = KEY_0;
304 263 cheatkeys[Cheat::ShowL1][0] = KEY_1;
305 263 cheatkeys[Cheat::ShowL2][0] = KEY_2;
306 263 cheatkeys[Cheat::ShowL3][0] = KEY_3;
307 263 cheatkeys[Cheat::ShowL4][0] = KEY_4;
308 263 cheatkeys[Cheat::ShowL5][0] = KEY_5;
309 263 cheatkeys[Cheat::ShowL6][0] = KEY_6;
310 263 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
311 263 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
312 263 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
313 263 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
314 263 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
315 263 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
316 263 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
317 263 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
318 263 }
319 263 void load_game_configs()
320 {
321 263 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"modules/classic.zmod"));
322 263 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
323 263 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
324 263 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
325 263 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
326 263 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
327 263 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
328 263 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
329 263 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
330 263 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
331 263 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
332 263 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
333 263 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
334 263 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
335 263 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
336
337 //cheat modifier keya
338 263 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
339 263 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
340 263 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
341 263 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
342
343 //cheat keys
344 263 load_default_cheatkeys();
345 char buf[256];
346
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 9468 times.
9731 for(size_t q = 1; q < Cheat::Last; ++q)
347 {
348
1/2
✓ Branch 0 taken 9468 times.
✗ Branch 1 not taken.
9468 if(!bindable_cheat((Cheat)q)) continue;
349 9468 std::string cheatname = cheat_to_string((Cheat)q);
350
1/2
✓ Branch 0 taken 9468 times.
✗ Branch 1 not taken.
9468 util::lowerstr(cheatname);
351 9468 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
352
1/2
✓ Branch 0 taken 9468 times.
✗ Branch 1 not taken.
9468 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
353 9468 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
354
1/2
✓ Branch 0 taken 9468 times.
✗ Branch 1 not taken.
9468 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
355 9468 }
356
357
1/2
✓ Branch 0 taken 263 times.
✗ Branch 1 not taken.
263 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
358 joystick_index = 0;
359
360 263 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
361 263 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
362 263 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
363 263 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
364 263 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
365 263 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
366 263 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
367 263 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
368 263 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
369 263 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
370
371 263 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
372 263 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
373 263 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
374 263 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
375
376 263 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
377 263 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
378 263 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
379 263 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
380 263 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
381 263 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
382 263 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
383 263 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
384 263 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
385 263 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
386 263 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
387
388 263 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
389 263 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
390 263 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
391 263 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
392
393 263 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
394
395 263 midi_volume = zc_get_config(sfx_sect,"midi",255);
396 263 sfx_volume = zc_get_config(sfx_sect,"sfx",255);
397 263 emusic_volume = zc_get_config(sfx_sect,"emusic",255);
398 263 pan_style = zc_get_config(sfx_sect,"pan",1);
399 263 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
400 263 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
401 263 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
402 263 Maxfps = zc_get_config(cfg_sect,"maxfps",0);
403 263 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
404 263 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
405 263 SnapshotScale = zc_get_config(cfg_sect,"snapshot_scale",2);
406 263 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
407 #ifdef __EMSCRIPTEN__
408 if (em_is_mobile()) NameEntryMode = 2;
409 #endif
410 263 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
411 263 ShowGameTime = zc_get_config(cfg_sect,"showtime",0);
412 263 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
413 263 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
414 263 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
415 263 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
416
417 263 window_width = resx = zc_get_config(cfg_sect,"window_width",-1);
418 263 window_height = resy = zc_get_config(cfg_sect,"window_height",-1);
419 263 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
420 263 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
421 263 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
422 263 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
423 263 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
424
425 263 loadlast = zc_get_config(cfg_sect,"load_last",0);
426
427 263 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
428
429 263 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
430 263 info_opacity = zc_get_config("zc","debug_info_opacity",255);
431 #ifdef _WIN32
432 console_enabled = (byte) zc_get_config("CONSOLE", "enabled", 0);
433 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
434 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
435
436 // This one's for Aero
437 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
438
439 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
440 #else //UNIX
441 263 console_enabled = (byte) zc_get_config("CONSOLE", "enabled", 0);
442 263 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
443 #endif
444 263 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
445 263 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
446
447 263 strcpy(qstdir,zc_get_config(cfg_sect,"quest_dir","quests"));
448 263 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
449 263 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
450 263 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
451 263 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
452 263 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
453 263 heart_beep = zc_get_config(cfg_sect,"heart_beep",0)!=0;
454 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
455 263 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
456 263 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
457 263 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
458 263 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
459 263 SkipTitle = zc_get_config(cfg_sect,"skip_title",0);
460 263 }
461
462 void save_control_configs(bool kb)
463 {
464 if(kb)
465 {
466 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
467 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
468 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
469 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
470
471 if (!replay_is_replaying())
472 {
473 zc_set_config(ctrl_sect,"key_a",Akey);
474 zc_set_config(ctrl_sect,"key_b",Bkey);
475 zc_set_config(ctrl_sect,"key_s",Skey);
476 zc_set_config(ctrl_sect,"key_l",Lkey);
477 zc_set_config(ctrl_sect,"key_r",Rkey);
478 zc_set_config(ctrl_sect,"key_p",Pkey);
479 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
480 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
481 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
482 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
483 zc_set_config(ctrl_sect,"key_up", DUkey);
484 zc_set_config(ctrl_sect,"key_down", DDkey);
485 zc_set_config(ctrl_sect,"key_left", DLkey);
486 zc_set_config(ctrl_sect,"key_right",DRkey);
487 }
488 }
489 else
490 {
491 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
492 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
493 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
494 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
495 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
496 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
497 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
498 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
499 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
500 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
501 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
502 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
503 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
504 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
505
506 zc_set_config(ctrl_sect,"btn_a",Abtn);
507 zc_set_config(ctrl_sect,"btn_b",Bbtn);
508 zc_set_config(ctrl_sect,"btn_s",Sbtn);
509 zc_set_config(ctrl_sect,"btn_m",Mbtn);
510 zc_set_config(ctrl_sect,"btn_l",Lbtn);
511 zc_set_config(ctrl_sect,"btn_r",Rbtn);
512 zc_set_config(ctrl_sect,"btn_p",Pbtn);
513 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
514 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
515 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
516 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
517
518 zc_set_config(ctrl_sect,"btn_up",DUbtn);
519 zc_set_config(ctrl_sect,"btn_down",DDbtn);
520 zc_set_config(ctrl_sect,"btn_left",DLbtn);
521 zc_set_config(ctrl_sect,"btn_right",DRbtn);
522 }
523 }
524
525 void save_cheatkeys()
526 {
527 char buf[256];
528 for(size_t q = 1; q < Cheat::Last; ++q)
529 {
530 if(!bindable_cheat((Cheat)q)) continue;
531 std::string cheatname = cheat_to_string((Cheat)q);
532 util::lowerstr(cheatname);
533 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
534 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
535 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
536 if(cheatkeys[q][1])
537 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
538 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
539 }
540 }
541
542 void save_game_configs()
543 {
544 packfile_password("");
545
546 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
547
548 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
549 {
550 int o_window_x, o_window_y;
551 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
552 zc_set_config(cfg_sect,"window_x",o_window_x);
553 zc_set_config(cfg_sect,"window_y",o_window_y);
554 }
555
556 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
557 {
558 window_width = al_get_display_width(all_get_display());
559 window_height = al_get_display_height(all_get_display());
560 zc_set_config(cfg_sect,"window_width",window_width);
561 zc_set_config(cfg_sect,"window_height",window_height);
562 }
563
564 zc_set_config(cfg_sect,"load_last",loadlast);
565 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
566
567 flush_config_file();
568 #ifdef __EMSCRIPTEN__
569 em_sync_fs();
570 #endif
571 }
572
573 //----------------------------------------------------------------
574
575 // Timers
576
577 47196 void fps_callback()
578 {
579 47196 lastfps=framecnt;
580 47196 framecnt=0;
581 47196 }
582
583 END_OF_FUNCTION(fps_callback)
584
585 263 int32_t Z_init_timers()
586 {
587 static bool didit = false;
588 const static char *err_str = "Couldn't allocate timer";
589 263 err_str = err_str; //Unused variable warning
590
591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 263 times.
263 if(didit)
592 return 1;
593
594 263 didit = true;
595
596 LOCK_VARIABLE(lastfps);
597 LOCK_VARIABLE(framecnt);
598 LOCK_FUNCTION(fps_callback);
599
600
1/2
✓ Branch 0 taken 263 times.
✗ Branch 1 not taken.
263 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
601 return 0;
602
603 263 return 1;
604 263 }
605
606 void Z_remove_timers()
607 {
608 remove_int(fps_callback);
609 }
610
611 //----------------------------------------------------------------
612
613 void go()
614 {
615 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
616 }
617
618 void comeback()
619 {
620 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
621 }
622
623 void dump_pal(BITMAP *dest)
624 {
625 for(int32_t i=0; i<256; i++)
626 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
627 }
628
629 //----------------------------------------------------------------
630
631 int game_mouse_index = ZCM_BLANK;
632 static bool system_mouse = false;
633 176 bool sys_mouse()
634 {
635 176 system_mouse = true;
636 176 return MouseSprite::set(ZCM_NORMAL);
637 }
638 1569 bool game_mouse()
639 {
640 1569 system_mouse = false;
641 1569 return MouseSprite::set(game_mouse_index);
642 }
643 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
644 {
645 if(!bmp)
646 return;
647 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
648 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
649 if(bmp->w == scaledw && bmp->h == scaledh)
650 user_scale = false;
651 if(user_scale || sys_recolor)
652 {
653 if(!user_scale) scale = 1;
654 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
655 if(user_scale)
656 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
657 else
658 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
659 if(sys_recolor)
660 recolor_mouse(tmpbmp);
661 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
662 destroy_bitmap(tmpbmp);
663 }
664 else
665 {
666 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
667 }
668 }
669
670 //Handles converting the mouse sprite from the .dat file
671 27 void recolor_mouse(BITMAP* bmp)
672 {
673
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 27 times.
459 for(int32_t x = 0; x < bmp->w; ++x)
674 {
675
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 432 times.
7344 for(int32_t y = 0; y < bmp->h; ++y)
676 {
677 6912 int32_t color = getpixel(bmp, x, y);
678
5/5
✓ Branch 0 taken 4698 times.
✓ Branch 1 taken 513 times.
✓ Branch 2 taken 594 times.
✓ Branch 3 taken 621 times.
✓ Branch 4 taken 486 times.
6912 switch(color)
679 {
680 case dvc(1):
681 513 color = jwin_pal[jcCURSORMISC];
682 513 break;
683 case dvc(2):
684 594 color = jwin_pal[jcCURSOROUTLINE];
685 594 break;
686 case dvc(3):
687 621 color = jwin_pal[jcCURSORLIGHT];
688 621 break;
689 case dvc(5):
690 486 color = jwin_pal[jcCURSORDARK];
691 486 break;
692 default:
693 4698 continue;
694 }
695 2214 putpixel(bmp, x, y, color);
696 2214 }
697 432 }
698 27 }
699 27 void load_mouse()
700 {
701 PALETTE pal;
702 27 BITMAP* cursor_bitmap = load_bitmap("assets/cursor.bmp", pal);
703
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if (!cursor_bitmap)
704 Z_error_fatal("Missing required file %s\n", "assets/cursor.bmp");
705
706 27 enter_sys_pal();
707 27 MouseSprite::set(-1);
708 27 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
709 27 int32_t sz = 16*scale;
710
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 27 times.
54 for(int32_t j = 0; j < 1; ++j)
711 {
712 27 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
713
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(zcmouse[j])
714 destroy_bitmap(zcmouse[j]);
715 27 zcmouse[j] = create_bitmap_ex(8,sz,sz);
716 27 clear_bitmap(zcmouse[j]);
717 27 clear_bitmap(tmpbmp);
718 27 blit(cursor_bitmap,tmpbmp,1,j*17+1,0,0,16,16);
719 27 recolor_mouse(tmpbmp);
720
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(sz!=16)
721 27 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
722 else
723 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
724 27 destroy_bitmap(tmpbmp);
725 27 }
726
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!hw_palette) hw_palette = &RAMpal;
727 27 zc_set_palette(*hw_palette);
728
729 27 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
730 27 clear_bitmap(blankmouse);
731
732 27 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
733 27 MouseSprite::assign(ZCM_BLANK, blankmouse);
734 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
735
736 //Reload the mouse
737
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(system_mouse)
738 27 sys_mouse();
739 else game_mouse();
740
741 27 destroy_bitmap(blankmouse);
742 27 destroy_bitmap(cursor_bitmap);
743 27 exit_sys_pal();
744 27 }
745
746 // sets the video mode and initializes the palette and mouse sprite
747 263 bool game_vid_mode(int32_t mode,int32_t wait)
748 {
749
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 27 times.
263 if (is_headless())
750 236 return true;
751
752 extern int zq_screen_w, zq_screen_h;
753
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(set_gfx_mode(mode,resx,resy,zq_screen_w,zq_screen_h)!=0)
754 {
755 return false;
756 }
757
758 27 scrx = (resx-320)>>1;
759 27 scry = (resy-240)>>1;
760
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 27 times.
54 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
761 27 zcmouse[q] = NULL;
762 27 load_mouse();
763
764
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 27 times.
459 for(int32_t i=240; i<256; i++)
765 432 RAMpal[i]=pal_gui[i];
766
767 27 zc_set_palette(RAMpal);
768 27 clear_to_color(screen,BLACK);
769
770 27 rest(wait);
771 27 return true;
772 263 }
773
774 272 void null_quest()
775 {
776 char qstdat_string[2048];
777 272 strcpy(qstdat_string, "modules/classic/default.qst");
778
779 #ifdef __EMSCRIPTEN__
780 // The quest template data file is not included because it's really big and isn't really needed
781 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
782 // which is much smaller.
783 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
784 #endif
785
786 272 byte skip_flags[4] = { 0 };
787
788 272 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
789 272 }
790
791 272 void init_NES_mode()
792 {
793 272 null_quest();
794 272 }
795
796 //----------------------------------------------------------------
797
798 qword trianglelines[16]=
799 {
800 0x0000000000000000ULL,
801 0xFD00000000000000ULL,
802 0xFDFD000000000000ULL,
803 0xFDFDFD0000000000ULL,
804 0xFDFDFDFD00000000ULL,
805 0xFDFDFDFDFD000000ULL,
806 0xFDFDFDFDFDFD0000ULL,
807 0xFDFDFDFDFDFDFD00ULL,
808 0xFDFDFDFDFDFDFDFDULL,
809 0x00FDFDFDFDFDFDFDULL,
810 0x0000FDFDFDFDFDFDULL,
811 0x000000FDFDFDFDFDULL,
812 0x00000000FDFDFDFDULL,
813 0x0000000000FDFDFDULL,
814 0x000000000000FDFDULL,
815 0x00000000000000FDULL,
816 };
817
818 word screen_triangles[28][32];
819 /*
820 qword triangles[4][16]= //[direction][value]
821 {
822 {
823 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
824 },
825 {
826 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
827 },
828 {
829 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
830 },
831 {
832 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
833 }
834 };
835 */
836
837
838 /*
839 byte triangles[4][16][8]= //[direction][value][line]
840 {
841 {
842 {
843 0, 0, 0, 0, 0, 0, 0, 0
844 },
845 {
846 1, 0, 0, 0, 0, 0, 0, 0
847 },
848 {
849 2, 1, 0, 0, 0, 0, 0, 0
850 },
851 {
852 3, 2, 1, 0, 0, 0, 0, 0
853 },
854 {
855 4, 3, 2, 1, 0, 0, 0, 0
856 },
857 {
858 5, 4, 3, 2, 1, 0, 0, 0
859 },
860 {
861 6, 5, 4, 3, 2, 1, 0, 0
862 },
863 {
864 7, 6, 5, 4, 3, 2, 1, 0
865 },
866 {
867 8, 7, 6, 5, 4, 3, 2, 1
868 },
869 {
870 8, 8, 7, 6, 5, 4, 3, 2
871 },
872 {
873 8, 8, 8, 7, 6, 5, 4, 3
874 },
875 {
876 8, 8, 8, 8, 7, 6, 5, 4
877 },
878 {
879 8, 8, 8, 8, 8, 7, 6, 5
880 },
881 {
882 8, 8, 8, 8, 8, 8, 7, 6
883 },
884 {
885 8, 8, 8, 8, 8, 8, 8, 7
886 },
887 {
888 8, 8, 8, 8, 8, 8, 8, 8
889 }
890 },
891 {
892 {
893 0, 0, 0, 0, 0, 0, 0, 0
894 },
895 {
896 15, 0, 0, 0, 0, 0, 0, 0
897 },
898 {
899 14, 15, 0, 0, 0, 0, 0, 0
900 },
901 {
902 13, 14, 15, 0, 0, 0, 0, 0
903 },
904 {
905 12, 13, 14, 15, 0, 0, 0, 0
906 },
907 {
908 11, 12, 13, 14, 15, 0, 0, 0
909 },
910 {
911 10, 11, 12, 13, 14, 15, 0, 0
912 },
913 {
914 9, 10, 11, 12, 13, 14, 15, 0
915 },
916 {
917 8, 9, 10, 11, 12, 13, 14, 15
918 },
919 {
920 8, 8, 9, 10, 11, 12, 13, 14
921 },
922 {
923 8, 8, 8, 9, 10, 11, 12, 13
924 },
925 {
926 8, 8, 8, 8, 9, 10, 11, 12
927 },
928 {
929 8, 8, 8, 8, 8, 9, 10, 11
930 },
931 {
932 8, 8, 8, 8, 8, 8, 9, 10
933 },
934 {
935 8, 8, 8, 8, 8, 8, 8, 9
936 },
937 {
938 8, 8, 8, 8, 8, 8, 8, 8
939 }
940 },
941 {
942 {
943 0, 0, 0, 0, 0, 0, 0, 0
944 },
945 {
946 0, 0, 0, 0, 0, 0, 0, 1
947 },
948 {
949 0, 0, 0, 0, 0, 0, 1, 2
950 },
951 {
952 0, 0, 0, 0, 0, 1, 2, 3
953 },
954 {
955 0, 0, 0, 0, 1, 2, 3, 4
956 },
957 {
958 0, 0, 0, 1, 2, 3, 4, 5
959 },
960 {
961 0, 0, 1, 2, 3, 4, 5, 6
962 },
963 {
964 0, 1, 2, 3, 4, 5, 6, 7
965 },
966 {
967 1, 2, 3, 4, 5, 6, 7, 8
968 },
969 {
970 2, 3, 4, 5, 6, 7, 8, 8
971 },
972 {
973 3, 4, 5, 6, 7, 8, 8, 8
974 },
975 {
976 4, 5, 6, 7, 8, 8, 8, 8
977 },
978 {
979 5, 6, 7, 8, 8, 8, 8, 8
980 },
981 {
982 6, 7, 8, 8, 8, 8, 8, 8
983 },
984 {
985 7, 8, 8, 8, 8, 8, 8, 8
986 },
987 {
988 8, 8, 8, 8, 8, 8, 8, 8
989 }
990 },
991 {
992 {
993 0, 0, 0, 0, 0, 0, 0, 0
994 },
995 {
996 0, 0, 0, 0, 0, 0, 0, 15
997 },
998 {
999 0, 0, 0, 0, 0, 0, 15, 14
1000 },
1001 {
1002 0, 0, 0, 0, 0, 15, 14, 13
1003 },
1004 {
1005 0, 0, 0, 0, 15, 14, 13, 12
1006 },
1007 {
1008 0, 0, 0, 15, 14, 13, 12, 11
1009 },
1010 {
1011 0, 0, 15, 14, 13, 12, 11, 10
1012 },
1013 {
1014 0, 15, 14, 13, 12, 11, 10, 9
1015 },
1016 {
1017 15, 14, 13, 12, 11, 10, 9, 8
1018 },
1019 {
1020 14, 13, 12, 11, 10, 9, 8, 8
1021 },
1022 {
1023 13, 12, 11, 10, 9, 8, 8, 8
1024 },
1025 {
1026 12, 11, 10, 9, 8, 8, 8, 8
1027 },
1028 {
1029 11, 10, 9, 8, 8, 8, 8, 8
1030 },
1031 {
1032 10, 9, 8, 8, 8, 8, 8, 8
1033 },
1034 {
1035 9, 8, 8, 8, 8, 8, 8, 8
1036 },
1037 {
1038 8, 8, 8, 8, 8, 8, 8, 8
1039 }
1040 }
1041 };
1042 */
1043
1044
1045
1046 /*
1047 for (int32_t blockrow=0; blockrow<30; ++i)
1048 {
1049 for (int32_t linerow=0; linerow<8; ++i)
1050 {
1051 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1052 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1053 {
1054 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1055 ++triangleline;
1056 }
1057 }
1058 }
1059 */
1060
1061 // the ULL suffixes are to prevent this warning:
1062 // warning: integer constant is too large for "int32_t" type
1063
1064 qword triangles[4][16][8]= //[direction][value][line]
1065 {
1066 {
1067 {
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL,
1075 0x0000000000000000ULL
1076 },
1077 {
1078 0xFD00000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL,
1085 0x0000000000000000ULL
1086 },
1087 {
1088 0xFDFD000000000000ULL,
1089 0xFD00000000000000ULL,
1090 0x0000000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL,
1095 0x0000000000000000ULL
1096 },
1097 {
1098 0xFDFDFD0000000000ULL,
1099 0xFDFD000000000000ULL,
1100 0xFD00000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL
1106 },
1107 {
1108 0xFDFDFDFD00000000ULL,
1109 0xFDFDFD0000000000ULL,
1110 0xFDFD000000000000ULL,
1111 0xFD00000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL
1116 },
1117 {
1118 0xFDFDFDFDFD000000ULL,
1119 0xFDFDFDFD00000000ULL,
1120 0xFDFDFD0000000000ULL,
1121 0xFDFD000000000000ULL,
1122 0xFD00000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL
1126 },
1127 {
1128 0xFDFDFDFDFDFD0000ULL,
1129 0xFDFDFDFDFD000000ULL,
1130 0xFDFDFDFD00000000ULL,
1131 0xFDFDFD0000000000ULL,
1132 0xFDFD000000000000ULL,
1133 0xFD00000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL
1136 },
1137 {
1138 0xFDFDFDFDFDFDFD00ULL,
1139 0xFDFDFDFDFDFD0000ULL,
1140 0xFDFDFDFDFD000000ULL,
1141 0xFDFDFDFD00000000ULL,
1142 0xFDFDFD0000000000ULL,
1143 0xFDFD000000000000ULL,
1144 0xFD00000000000000ULL,
1145 0x0000000000000000ULL
1146 },
1147 {
1148 0xFDFDFDFDFDFDFDFDULL,
1149 0xFDFDFDFDFDFDFD00ULL,
1150 0xFDFDFDFDFDFD0000ULL,
1151 0xFDFDFDFDFD000000ULL,
1152 0xFDFDFDFD00000000ULL,
1153 0xFDFDFD0000000000ULL,
1154 0xFDFD000000000000ULL,
1155 0xFD00000000000000ULL
1156 },
1157 {
1158 0xFDFDFDFDFDFDFDFDULL,
1159 0xFDFDFDFDFDFDFDFDULL,
1160 0xFDFDFDFDFDFDFD00ULL,
1161 0xFDFDFDFDFDFD0000ULL,
1162 0xFDFDFDFDFD000000ULL,
1163 0xFDFDFDFD00000000ULL,
1164 0xFDFDFD0000000000ULL,
1165 0xFDFD000000000000ULL
1166 },
1167 {
1168 0xFDFDFDFDFDFDFDFDULL,
1169 0xFDFDFDFDFDFDFDFDULL,
1170 0xFDFDFDFDFDFDFDFDULL,
1171 0xFDFDFDFDFDFDFD00ULL,
1172 0xFDFDFDFDFDFD0000ULL,
1173 0xFDFDFDFDFD000000ULL,
1174 0xFDFDFDFD00000000ULL,
1175 0xFDFDFD0000000000ULL
1176 },
1177 {
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFDFDULL,
1182 0xFDFDFDFDFDFDFD00ULL,
1183 0xFDFDFDFDFDFD0000ULL,
1184 0xFDFDFDFDFD000000ULL,
1185 0xFDFDFDFD00000000ULL
1186 },
1187 {
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFDFDULL,
1193 0xFDFDFDFDFDFDFD00ULL,
1194 0xFDFDFDFDFDFD0000ULL,
1195 0xFDFDFDFDFD000000ULL
1196 },
1197 {
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFD00ULL,
1205 0xFDFDFDFDFDFD0000ULL
1206 },
1207 {
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFDFDULL,
1215 0xFDFDFDFDFDFDFD00ULL
1216 },
1217 {
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0xFDFDFDFDFDFDFDFDULL
1226 }
1227 },
1228 {
1229 {
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL,
1237 0x0000000000000000ULL
1238 },
1239 {
1240 0x00000000000000FDULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL,
1247 0x0000000000000000ULL
1248 },
1249 {
1250 0x000000000000FDFDULL,
1251 0x00000000000000FDULL,
1252 0x0000000000000000ULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL,
1257 0x0000000000000000ULL
1258 },
1259 {
1260 0x0000000000FDFDFDULL,
1261 0x000000000000FDFDULL,
1262 0x00000000000000FDULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL
1268 },
1269 {
1270 0x00000000FDFDFDFDULL,
1271 0x0000000000FDFDFDULL,
1272 0x000000000000FDFDULL,
1273 0x00000000000000FDULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL
1278 },
1279 {
1280 0x000000FDFDFDFDFDULL,
1281 0x00000000FDFDFDFDULL,
1282 0x0000000000FDFDFDULL,
1283 0x000000000000FDFDULL,
1284 0x00000000000000FDULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL
1288 },
1289 {
1290 0x0000FDFDFDFDFDFDULL,
1291 0x000000FDFDFDFDFDULL,
1292 0x00000000FDFDFDFDULL,
1293 0x0000000000FDFDFDULL,
1294 0x000000000000FDFDULL,
1295 0x00000000000000FDULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL
1298 },
1299 {
1300 0x00FDFDFDFDFDFDFDULL,
1301 0x0000FDFDFDFDFDFDULL,
1302 0x000000FDFDFDFDFDULL,
1303 0x00000000FDFDFDFDULL,
1304 0x0000000000FDFDFDULL,
1305 0x000000000000FDFDULL,
1306 0x00000000000000FDULL,
1307 0x0000000000000000ULL
1308 },
1309 {
1310 0xFDFDFDFDFDFDFDFDULL,
1311 0x00FDFDFDFDFDFDFDULL,
1312 0x0000FDFDFDFDFDFDULL,
1313 0x000000FDFDFDFDFDULL,
1314 0x00000000FDFDFDFDULL,
1315 0x0000000000FDFDFDULL,
1316 0x000000000000FDFDULL,
1317 0x00000000000000FDULL
1318 },
1319 {
1320 0xFDFDFDFDFDFDFDFDULL,
1321 0xFDFDFDFDFDFDFDFDULL,
1322 0x00FDFDFDFDFDFDFDULL,
1323 0x0000FDFDFDFDFDFDULL,
1324 0x000000FDFDFDFDFDULL,
1325 0x00000000FDFDFDFDULL,
1326 0x0000000000FDFDFDULL,
1327 0x000000000000FDFDULL
1328 },
1329 {
1330 0xFDFDFDFDFDFDFDFDULL,
1331 0xFDFDFDFDFDFDFDFDULL,
1332 0xFDFDFDFDFDFDFDFDULL,
1333 0x00FDFDFDFDFDFDFDULL,
1334 0x0000FDFDFDFDFDFDULL,
1335 0x000000FDFDFDFDFDULL,
1336 0x00000000FDFDFDFDULL,
1337 0x0000000000FDFDFDULL
1338 },
1339 {
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0x00FDFDFDFDFDFDFDULL,
1345 0x0000FDFDFDFDFDFDULL,
1346 0x000000FDFDFDFDFDULL,
1347 0x00000000FDFDFDFDULL
1348 },
1349 {
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL,
1355 0x00FDFDFDFDFDFDFDULL,
1356 0x0000FDFDFDFDFDFDULL,
1357 0x000000FDFDFDFDFDULL
1358 },
1359 {
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0x00FDFDFDFDFDFDFDULL,
1367 0x0000FDFDFDFDFDFDULL
1368 },
1369 {
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0xFDFDFDFDFDFDFDFDULL,
1377 0x00FDFDFDFDFDFDFDULL
1378 },
1379 {
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL,
1387 0xFDFDFDFDFDFDFDFDULL
1388 }
1389 },
1390 {
1391 {
1392 0x0000000000000000ULL,
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL,
1399 0x0000000000000000ULL
1400 },
1401 {
1402 0x0000000000000000ULL,
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0x0000000000000000ULL,
1408 0x0000000000000000ULL,
1409 0xFD00000000000000ULL
1410 },
1411 {
1412 0x0000000000000000ULL,
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0x0000000000000000ULL,
1418 0xFD00000000000000ULL,
1419 0xFDFD000000000000ULL
1420 },
1421 {
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0xFD00000000000000ULL,
1428 0xFDFD000000000000ULL,
1429 0xFDFDFD0000000000ULL
1430 },
1431 {
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0xFD00000000000000ULL,
1437 0xFDFD000000000000ULL,
1438 0xFDFDFD0000000000ULL,
1439 0xFDFDFDFD00000000ULL
1440 },
1441 {
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0xFD00000000000000ULL,
1446 0xFDFD000000000000ULL,
1447 0xFDFDFD0000000000ULL,
1448 0xFDFDFDFD00000000ULL,
1449 0xFDFDFDFDFD000000ULL
1450 },
1451 {
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0xFD00000000000000ULL,
1455 0xFDFD000000000000ULL,
1456 0xFDFDFD0000000000ULL,
1457 0xFDFDFDFD00000000ULL,
1458 0xFDFDFDFDFD000000ULL,
1459 0xFDFDFDFDFDFD0000ULL
1460 },
1461 {
1462 0x0000000000000000ULL,
1463 0xFD00000000000000ULL,
1464 0xFDFD000000000000ULL,
1465 0xFDFDFD0000000000ULL,
1466 0xFDFDFDFD00000000ULL,
1467 0xFDFDFDFDFD000000ULL,
1468 0xFDFDFDFDFDFD0000ULL,
1469 0xFDFDFDFDFDFDFD00ULL
1470 },
1471 {
1472 0xFD00000000000000ULL,
1473 0xFDFD000000000000ULL,
1474 0xFDFDFD0000000000ULL,
1475 0xFDFDFDFD00000000ULL,
1476 0xFDFDFDFDFD000000ULL,
1477 0xFDFDFDFDFDFD0000ULL,
1478 0xFDFDFDFDFDFDFD00ULL,
1479 0xFDFDFDFDFDFDFDFDULL
1480 },
1481 {
1482 0xFDFD000000000000ULL,
1483 0xFDFDFD0000000000ULL,
1484 0xFDFDFDFD00000000ULL,
1485 0xFDFDFDFDFD000000ULL,
1486 0xFDFDFDFDFDFD0000ULL,
1487 0xFDFDFDFDFDFDFD00ULL,
1488 0xFDFDFDFDFDFDFDFDULL,
1489 0xFDFDFDFDFDFDFDFDULL
1490 },
1491 {
1492 0xFDFDFD0000000000ULL,
1493 0xFDFDFDFD00000000ULL,
1494 0xFDFDFDFDFD000000ULL,
1495 0xFDFDFDFDFDFD0000ULL,
1496 0xFDFDFDFDFDFDFD00ULL,
1497 0xFDFDFDFDFDFDFDFDULL,
1498 0xFDFDFDFDFDFDFDFDULL,
1499 0xFDFDFDFDFDFDFDFDULL
1500 },
1501 {
1502 0xFDFDFDFD00000000ULL,
1503 0xFDFDFDFDFD000000ULL,
1504 0xFDFDFDFDFDFD0000ULL,
1505 0xFDFDFDFDFDFDFD00ULL,
1506 0xFDFDFDFDFDFDFDFDULL,
1507 0xFDFDFDFDFDFDFDFDULL,
1508 0xFDFDFDFDFDFDFDFDULL,
1509 0xFDFDFDFDFDFDFDFDULL
1510 },
1511 {
1512 0xFDFDFDFDFD000000ULL,
1513 0xFDFDFDFDFDFD0000ULL,
1514 0xFDFDFDFDFDFDFD00ULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL
1520 },
1521 {
1522 0xFDFDFDFDFDFD0000ULL,
1523 0xFDFDFDFDFDFDFD00ULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL
1530 },
1531 {
1532 0xFDFDFDFDFDFDFD00ULL,
1533 0xFDFDFDFDFDFDFDFDULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL
1540 },
1541 {
1542 0xFDFDFDFDFDFDFDFDULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL
1550 }
1551 },
1552 {
1553 {
1554 0x0000000000000000ULL,
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL,
1561 0x0000000000000000ULL
1562 },
1563 {
1564 0x0000000000000000ULL,
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x0000000000000000ULL,
1570 0x0000000000000000ULL,
1571 0x00000000000000FDULL
1572 },
1573 {
1574 0x0000000000000000ULL,
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x0000000000000000ULL,
1580 0x00000000000000FDULL,
1581 0x000000000000FDFDULL
1582 },
1583 {
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x00000000000000FDULL,
1590 0x000000000000FDFDULL,
1591 0x0000000000FDFDFDULL
1592 },
1593 {
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x00000000000000FDULL,
1599 0x000000000000FDFDULL,
1600 0x0000000000FDFDFDULL,
1601 0x00000000FDFDFDFDULL
1602 },
1603 {
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x00000000000000FDULL,
1608 0x000000000000FDFDULL,
1609 0x0000000000FDFDFDULL,
1610 0x00000000FDFDFDFDULL,
1611 0x000000FDFDFDFDFDULL
1612 },
1613 {
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x00000000000000FDULL,
1617 0x000000000000FDFDULL,
1618 0x0000000000FDFDFDULL,
1619 0x00000000FDFDFDFDULL,
1620 0x000000FDFDFDFDFDULL,
1621 0x0000FDFDFDFDFDFDULL
1622 },
1623 {
1624 0x0000000000000000ULL,
1625 0x00000000000000FDULL,
1626 0x000000000000FDFDULL,
1627 0x0000000000FDFDFDULL,
1628 0x00000000FDFDFDFDULL,
1629 0x000000FDFDFDFDFDULL,
1630 0x0000FDFDFDFDFDFDULL,
1631 0x00FDFDFDFDFDFDFDULL
1632 },
1633 {
1634 0x00000000000000FDULL,
1635 0x000000000000FDFDULL,
1636 0x0000000000FDFDFDULL,
1637 0x00000000FDFDFDFDULL,
1638 0x000000FDFDFDFDFDULL,
1639 0x0000FDFDFDFDFDFDULL,
1640 0x00FDFDFDFDFDFDFDULL,
1641 0xFDFDFDFDFDFDFDFDULL
1642 },
1643 {
1644 0x000000000000FDFDULL,
1645 0x0000000000FDFDFDULL,
1646 0x00000000FDFDFDFDULL,
1647 0x000000FDFDFDFDFDULL,
1648 0x0000FDFDFDFDFDFDULL,
1649 0x00FDFDFDFDFDFDFDULL,
1650 0xFDFDFDFDFDFDFDFDULL,
1651 0xFDFDFDFDFDFDFDFDULL
1652 },
1653 {
1654 0x0000000000FDFDFDULL,
1655 0x00000000FDFDFDFDULL,
1656 0x000000FDFDFDFDFDULL,
1657 0x0000FDFDFDFDFDFDULL,
1658 0x00FDFDFDFDFDFDFDULL,
1659 0xFDFDFDFDFDFDFDFDULL,
1660 0xFDFDFDFDFDFDFDFDULL,
1661 0xFDFDFDFDFDFDFDFDULL
1662 },
1663 {
1664 0x00000000FDFDFDFDULL,
1665 0x000000FDFDFDFDFDULL,
1666 0x0000FDFDFDFDFDFDULL,
1667 0x00FDFDFDFDFDFDFDULL,
1668 0xFDFDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL
1672 },
1673 {
1674 0x000000FDFDFDFDFDULL,
1675 0x0000FDFDFDFDFDFDULL,
1676 0x00FDFDFDFDFDFDFDULL,
1677 0xFDFDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL
1682 },
1683 {
1684 0x0000FDFDFDFDFDFDULL,
1685 0x00FDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL
1692 },
1693 {
1694 0x00FDFDFDFDFDFDFDULL,
1695 0xFDFDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL
1702 },
1703 {
1704 0xFDFDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL
1712 }
1713 }
1714 };
1715
1716 int32_t black_opening_count=0;
1717 int32_t black_opening_x,black_opening_y;
1718 int32_t black_opening_shape;
1719
1720 3228 int32_t choose_opening_shape()
1721 {
1722 // First, count how many bits are set
1723 3228 int32_t numBits=0;
1724 int32_t bitCounter;
1725
1726
2/2
✓ Branch 0 taken 16140 times.
✓ Branch 1 taken 3228 times.
19368 for(int32_t i=0; i<bosMAX; i++)
1727 {
1728
2/2
✓ Branch 0 taken 12696 times.
✓ Branch 1 taken 3444 times.
16140 if(COOLSCROLL&(1<<i))
1729 3444 numBits++;
1730 16140 }
1731
1732 // Shouldn't happen...
1733
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(numBits==0)
1734 return bosCIRCLE;
1735
1736 // Pick a bit
1737 3228 bitCounter=zc_rand()%numBits+1;
1738
1739
2/2
✓ Branch 0 taken 4419 times.
✓ Branch 1 taken 26 times.
4445 for(int32_t i=0; i<bosMAX; i++)
1740 {
1741 // If this bit is set, decrement the bit counter
1742
2/2
✓ Branch 0 taken 1061 times.
✓ Branch 1 taken 3358 times.
4419 if(COOLSCROLL&(1<<i))
1743 3358 bitCounter--;
1744
1745 // When the counter hits 0, return a value based on
1746 // which bit it stopped on.
1747 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1748
2/2
✓ Branch 0 taken 3202 times.
✓ Branch 1 taken 1217 times.
4419 if(bitCounter==0)
1749 3202 return i;
1750 1217 }
1751
1752 // Shouldn't be necessary, but the compiler might complain, at least
1753 26 return bosCIRCLE;
1754 3228 }
1755
1756 727 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1757 {
1758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 727 times.
727 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1759
1760 727 int32_t w=256, h=224;
1761 727 int32_t blockrows=28, blockcolumns=32;
1762 727 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1763
1764
2/2
✓ Branch 0 taken 20356 times.
✓ Branch 1 taken 727 times.
21083 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1765 {
1766
2/2
✓ Branch 0 taken 651392 times.
✓ Branch 1 taken 20356 times.
671748 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1767 {
1768
2/2
✓ Branch 0 taken 269309 times.
✓ Branch 1 taken 382083 times.
651392 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1769 651392 }
1770 20356 }
1771
1772 727 black_opening_count = 66;
1773 727 black_opening_x = x;
1774 727 black_opening_y = y;
1775 727 lensclk = 0;
1776 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1777
1778
1779
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(black_opening_shape == bosFADEBLACK)
1780 {
1781 refreshTints();
1782 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1783 }
1784
2/2
✓ Branch 0 taken 723 times.
✓ Branch 1 taken 4 times.
727 if(wait)
1785 {
1786 4 FFCore.warpScriptCheck();
1787
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 264 times.
268 for(int32_t i=0; i<66; i++)
1788 {
1789 264 draw_screen(tmpscr);
1790 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1791 264 advanceframe(true);
1792
1793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if(Quit)
1794 {
1795 break;
1796 }
1797 264 }
1798 4 }
1799 727 }
1800
1801 2501 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1802 {
1803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2501 times.
2501 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1804
1805 2501 int32_t w=256, h=224;
1806 2501 int32_t blockrows=28, blockcolumns=32;
1807 2501 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1808
1809
2/2
✓ Branch 0 taken 70028 times.
✓ Branch 1 taken 2501 times.
72529 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1810 {
1811
2/2
✓ Branch 0 taken 2240896 times.
✓ Branch 1 taken 70028 times.
2310924 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1812 {
1813
2/2
✓ Branch 0 taken 1103973 times.
✓ Branch 1 taken 1136923 times.
2240896 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1814 2240896 }
1815 70028 }
1816
1817 2501 black_opening_count = -66;
1818 2501 black_opening_x = x;
1819 2501 black_opening_y = y;
1820 2501 lensclk = 0;
1821
1/2
✓ Branch 0 taken 2501 times.
✗ Branch 1 not taken.
2501 if(black_opening_shape == bosFADEBLACK)
1822 {
1823 refreshTints();
1824 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1825 }
1826
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 2136 times.
2501 if(wait)
1827 {
1828 2136 FFCore.warpScriptCheck();
1829
2/2
✓ Branch 0 taken 2135 times.
✓ Branch 1 taken 140979 times.
143114 for(int32_t i=0; i<66; i++)
1830 {
1831 140979 draw_screen(tmpscr);
1832 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1833 140979 advanceframe(true);
1834
1835
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 140978 times.
140979 if(Quit)
1836 {
1837 1 break;
1838 }
1839 140978 }
1840 2136 }
1841 2501 }
1842
1843 212467 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1844 {
1845 212467 clear_to_color(tmp_scr,BLACK);
1846 212467 int32_t w=256, h=224;
1847
1848
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9636 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 20262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 181909 times.
212467 switch(black_opening_shape)
1849 {
1850 case bosOVAL:
1851 {
1852 9636 double new_w=(w/2)+abs(w/2-x);
1853 9636 double new_h=(h/2)+abs(h/2-y);
1854 9636 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1855 9636 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1856 9636 break;
1857 }
1858
1859 case bosTRIANGLE:
1860 {
1861 660 double new_w=(w/2)+abs(w/2-x);
1862 660 double new_h=(h/2)+abs(h/2-y);
1863 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1864 660 double P2= (PI/2);
1865 660 double P23=(2*PI/3);
1866 660 double P43=(4*PI/3);
1867 660 double Pa= (-4*PI*a/(3*max_a));
1868 660 double angle=P2+Pa;
1869 660 double a0=angle;
1870 660 double a2=angle+P23;
1871 660 double a4=angle+P43;
1872 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1873 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1874 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1875 0);
1876 660 break;
1877 }
1878
1879 case bosSMAS:
1880 {
1881
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 13068 times.
20262 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1882
1883
2/2
✓ Branch 0 taken 567336 times.
✓ Branch 1 taken 20262 times.
587598 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1884 {
1885
2/2
✓ Branch 0 taken 4538688 times.
✓ Branch 1 taken 567336 times.
5106024 for(int32_t linerow=0; linerow<8; ++linerow)
1886 {
1887 4538688 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1888
1889
2/2
✓ Branch 0 taken 145238016 times.
✓ Branch 1 taken 4538688 times.
149776704 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1890 {
1891 435714048 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1892
6/6
✓ Branch 0 taken 104912184 times.
✓ Branch 1 taken 40325832 times.
✓ Branch 2 taken 95821040 times.
✓ Branch 3 taken 49416976 times.
✓ Branch 4 taken 55495208 times.
✓ Branch 5 taken 40325832 times.
145238016 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1893 145238016 [linerow];
1894 145238016 ++triangleline;
1895
1896
2/2
✓ Branch 0 taken 127083264 times.
✓ Branch 1 taken 18154752 times.
145238016 if(linerow==0)
1897 {
1898 18154752 }
1899 145238016 }
1900 4538688 }
1901 567336 }
1902
1903 20262 break;
1904 }
1905
1906 case bosFADEBLACK:
1907 {
1908 if(black_opening_count<0)
1909 {
1910 black_fade(zc_min(-black_opening_count,63));
1911 }
1912 else if(black_opening_count>0)
1913 {
1914 black_fade(63-zc_max(black_opening_count-3,0));
1915 }
1916 else black_fade(0);
1917 return; //no blitting from tmp_scr!
1918 }
1919
1920 181909 case bosCIRCLE:
1921 default:
1922 {
1923 181909 double new_w=(w/2)+abs(w/2-x);
1924 181909 double new_h=(h/2)+abs(h/2-y);
1925 181909 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1926 //circlefill(tmp_scr,x,y,a<<3,0);
1927 181909 circlefill(tmp_scr,x,y,r,0);
1928 181909 break;
1929 }
1930 }
1931
1932 212467 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1933 212467 }
1934
1935
1936 void black_fade(int32_t fadeamnt)
1937 {
1938 for(int32_t i=0; i < 0xEF; i++)
1939 {
1940 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1941 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1942 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1943 }
1944
1945 refreshpal = true;
1946 }
1947
1948 //----------------------------------------------------------------
1949
1950 200169944 bool item_disabled(int32_t item) //is this item disabled?
1951 {
1952
2/2
✓ Branch 0 taken 14429052 times.
✓ Branch 1 taken 185740892 times.
200169944 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1953 }
1954
1955 15453208 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1956 {
1957
2/2
✓ Branch 0 taken 188072 times.
✓ Branch 1 taken 15265136 times.
15453208 if(current_item(item_type, true) >=item)
1958 {
1959 188072 return true;
1960 }
1961
1962 15265136 return false;
1963 15453208 }
1964
1965 48039028 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1966 {
1967
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4363819 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4902235 times.
✓ Branch 6 taken 28693221 times.
✓ Branch 7 taken 9885299 times.
✓ Branch 8 taken 194454 times.
48039028 switch(item_type)
1968 {
1969 case itype_bomb:
1970 case itype_sbomb:
1971 {
1972 int32_t itemid = getItemID(itemsbuf, item_type, it);
1973
1974 if(itemid == -1)
1975 return false;
1976
1977 return (game->get_item(itemid));
1978 }
1979
1980 case itype_clock:
1981 {
1982 4363819 int32_t itemid = getItemID(itemsbuf, item_type, it);
1983
1984
2/4
✓ Branch 0 taken 4363819 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4363819 times.
✗ Branch 3 not taken.
4363819 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1985 return (game->get_item(itemid));
1986 4363819 return Hero.getClock()?1:0;
1987 }
1988
1989 case itype_key:
1990 return (game->get_keys()>0);
1991
1992 case itype_magiccontainer:
1993 return (game->get_maxmagic()>=game->get_mp_per_block());
1994
1995 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1996 {
1997
2/3
✓ Branch 0 taken 321216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4581019 times.
4902235 switch(it)
1998 {
1999 case -2:
2000 {
2001 for(int32_t i=0; i<MAXLEVELS; i++)
2002 {
2003 if(game->lvlitems[i]&liTRIFORCE)
2004 {
2005 return true;
2006 }
2007 }
2008
2009 return false;
2010 }
2011
2012 case -1:
2013 4581019 return (game->lvlitems[dlevel]&liTRIFORCE);
2014
2015 default:
2016
2/4
✓ Branch 0 taken 321216 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 321216 times.
321216 if(it>=0&&it<MAXLEVELS)
2017 {
2018 321216 return (game->lvlitems[it]&liTRIFORCE);
2019 }
2020
2021 break;
2022 }
2023
2024 return 0;
2025 }
2026
2027 case itype_map: //it: -2=any, -1=current level, other=that level
2028 {
2029
2/3
✓ Branch 0 taken 540402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28152819 times.
28693221 switch(it)
2030 {
2031 case -2:
2032 {
2033 for(int32_t i=0; i<MAXLEVELS; i++)
2034 {
2035 if(game->lvlitems[i]&liMAP)
2036 {
2037 return true;
2038 }
2039 }
2040
2041 return false;
2042 }
2043
2044 case -1:
2045 28152819 return (game->lvlitems[dlevel]&liMAP)!=0;
2046
2047 default:
2048
2/4
✓ Branch 0 taken 540402 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 540402 times.
540402 if(it>=0&&it<MAXLEVELS)
2049 {
2050 540402 return (game->lvlitems[it]&liMAP)!=0;
2051 }
2052
2053 break;
2054 }
2055
2056 return 0;
2057 }
2058
2059 case itype_compass: //it: -2=any, -1=current level, other=that level
2060 {
2061
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 9885299 times.
9885299 switch(it)
2062 {
2063 case -2:
2064 {
2065 for(int32_t i=0; i<MAXLEVELS; i++)
2066 {
2067 if(game->lvlitems[i]&liCOMPASS)
2068 {
2069 return true;
2070 }
2071 }
2072
2073 return false;
2074 }
2075
2076 case -1:
2077 9885299 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2078
2079 default:
2080 if(it>=0&&it<MAXLEVELS)
2081 {
2082 return (game->lvlitems[it]&liCOMPASS)!=0;
2083 }
2084
2085 break;
2086 }
2087 return 0;
2088 }
2089
2090 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2091 {
2092
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 194454 times.
194454 switch(it)
2093 {
2094 case -2:
2095 {
2096 for(int32_t i=0; i<MAXLEVELS; i++)
2097 {
2098 if(game->lvlitems[i]&liBOSSKEY)
2099 {
2100 return true;
2101 }
2102 }
2103
2104 return false;
2105 }
2106
2107 case -1:
2108 194454 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2109
2110 default:
2111 if(it>=0&&it<MAXLEVELS)
2112 {
2113 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2114 }
2115 break;
2116 }
2117 return 0;
2118 }
2119
2120 default:
2121 //it=(1<<(it-1));
2122 /*if (item_type>=itype_max)
2123 {
2124 enter_sys_pal();
2125 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2126 exit_sys_pal();
2127
2128 return false;
2129 }*/
2130 int32_t itemid = getItemID(itemsbuf, item_type, it);
2131
2132 if(itemid == -1)
2133 return false;
2134
2135 return game->get_item(itemid);
2136 }
2137 48039028 }
2138
2139 149141874 int current_item(int item_type, bool checkmagic, bool jinx_check, bool check_bunny)
2140 {
2141
9/9
✓ Branch 0 taken 4363819 times.
✓ Branch 1 taken 114231322 times.
✓ Branch 2 taken 4363819 times.
✓ Branch 3 taken 4363819 times.
✓ Branch 4 taken 4363819 times.
✓ Branch 5 taken 4363819 times.
✓ Branch 6 taken 4363819 times.
✓ Branch 7 taken 4363819 times.
✓ Branch 8 taken 4363819 times.
149141874 switch(item_type)
2142 {
2143 case itype_clock:
2144 {
2145 4363819 int maxid = current_item_id(item_type, checkmagic, jinx_check, check_bunny);
2146
2147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4363819 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4363819 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2148 return itemsbuf[maxid].fam_type;
2149
2150 4363819 return has_item(itype_clock,1) ? 1 : 0;
2151 }
2152
2153 case itype_key:
2154 4363819 return game->get_keys();
2155
2156 case itype_lkey:
2157 4363819 return game->lvlkeys[get_dlevel()];
2158
2159 case itype_magiccontainer:
2160 4363819 return game->get_maxmagic()/game->get_mp_per_block();
2161
2162 case itype_triforcepiece:
2163 {
2164 4363819 int count=0;
2165
2166
2/2
✓ Branch 0 taken 2234275328 times.
✓ Branch 1 taken 4363819 times.
2238639147 for(int i=0; i<MAXLEVELS; i++)
2167 {
2168 2234275328 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2169 2234275328 }
2170
2171 4363819 return count;
2172 }
2173
2174 case itype_map:
2175 {
2176 4363819 int count=0;
2177
2178
2/2
✓ Branch 0 taken 2234275328 times.
✓ Branch 1 taken 4363819 times.
2238639147 for(int i=0; i<MAXLEVELS; i++)
2179 {
2180 2234275328 count+=(game->lvlitems[i]&liMAP)?1:0;
2181 2234275328 }
2182
2183 4363819 return count;
2184 }
2185
2186 case itype_compass:
2187 {
2188 4363819 int count=0;
2189
2190
2/2
✓ Branch 0 taken 2234275328 times.
✓ Branch 1 taken 4363819 times.
2238639147 for(int i=0; i<MAXLEVELS; i++)
2191 {
2192 2234275328 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2193 2234275328 }
2194
2195 4363819 return count;
2196 }
2197
2198 case itype_bosskey:
2199 {
2200 4363819 int count=0;
2201
2202
2/2
✓ Branch 0 taken 2234275328 times.
✓ Branch 1 taken 4363819 times.
2238639147 for(int i=0; i<MAXLEVELS; i++)
2203 {
2204 2234275328 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2205 2234275328 }
2206
2207 4363819 return count;
2208 }
2209
2210 default:
2211 114231322 int maxid = current_item_id(item_type, checkmagic, jinx_check, check_bunny);
2212
2213
2/2
✓ Branch 0 taken 33015566 times.
✓ Branch 1 taken 81215756 times.
114231322 if(maxid == -1)
2214 81215756 return 0;
2215
2216 33015566 return itemsbuf[maxid].fam_type;
2217 }
2218 149141874 }
2219
2220 351 std::map<int32_t, int32_t> itemcache;
2221 351 std::map<int32_t, int32_t> itemcache_cost;
2222
2223 void removeFromItemCache(int32_t itemclass)
2224 {
2225 itemcache.erase(itemclass);
2226 itemcache_cost.erase(itemclass);
2227 cache_tile_mod_clear();
2228 }
2229
2230 12381377 void flushItemCache(bool justcost)
2231 {
2232 12381377 itemcache_cost.clear();
2233
2/2
✓ Branch 0 taken 12315028 times.
✓ Branch 1 taken 66349 times.
12381377 if(!justcost)
2234 66349 itemcache.clear();
2235
2/2
✓ Branch 0 taken 5826470 times.
✓ Branch 1 taken 6488558 times.
12315028 else if(replay_version_check(0,19))
2236 5826470 return;
2237
2238 6554907 cache_tile_mod_clear();
2239
2240 //also fix the active subscreen if items were deleted -DD
2241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6554907 times.
6554907 if(game != NULL)
2242 {
2243 6554907 verifyBothWeapons();
2244 6554907 refresh_subscr_items();
2245 6554907 }
2246 12381377 }
2247
2248 // This is used often, so it should be as direct as possible.
2249 2942846398 int _c_item_id_internal(int itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2250 {
2251 2942846398 bool use_cost_cache = replay_version_check(19);
2252
2/2
✓ Branch 0 taken 2822918148 times.
✓ Branch 1 taken 119928250 times.
2942846398 if(jinx_check)
2253 {
2254
4/4
✓ Branch 0 taken 86883166 times.
✓ Branch 1 taken 33045084 times.
✓ Branch 2 taken 11013560 times.
✓ Branch 3 taken 75869606 times.
119928250 if(!(HeroSwordClk() || HeroItemClk()))
2255 75869606 jinx_check = false; //not jinxed
2256 119928250 }
2257
4/4
✓ Branch 0 taken 103098 times.
✓ Branch 1 taken 2942743300 times.
✓ Branch 2 taken 1853 times.
✓ Branch 3 taken 101245 times.
2942846398 if(!Hero.BunnyClock() || itemtype == itype_pearl) // bunny_check does not apply
2258 2942745153 check_bunny = false;
2259
2/2
✓ Branch 0 taken 2886978547 times.
✓ Branch 1 taken 55867851 times.
2942846398 if(itemtype == itype_ring) checkmagic = true;
2260
4/4
✓ Branch 0 taken 2898787754 times.
✓ Branch 1 taken 44058644 times.
✓ Branch 2 taken 274389087 times.
✓ Branch 3 taken 23761870 times.
3240997355 if (!jinx_check && !check_bunny
2261
4/4
✓ Branch 0 taken 2898708507 times.
✓ Branch 1 taken 79247 times.
✓ Branch 2 taken 298150957 times.
✓ Branch 3 taken 2600557550 times.
2898787754 && (use_cost_cache || itemtype != itype_ring))
2262 {
2263
4/4
✓ Branch 0 taken 537567272 times.
✓ Branch 1 taken 2337379365 times.
✓ Branch 2 taken 232608595 times.
✓ Branch 3 taken 304958677 times.
2874946637 auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
2264 2874946637 auto res = cache.find(itemtype);
2265
2266
2/2
✓ Branch 0 taken 2731005213 times.
✓ Branch 1 taken 143941424 times.
2874946637 if(res != cache.end())
2267 2731005213 return res->second;
2268 143941424 }
2269
2270 211841185 int result = -1;
2271 211841185 int highestlevel = -1;
2272
2273
2/2
✓ Branch 0 taken 54231343360 times.
✓ Branch 1 taken 211841185 times.
54443184545 for(int i=0; i<MAXITEMS; i++)
2274 {
2275
6/6
✓ Branch 0 taken 5952210167 times.
✓ Branch 1 taken 48279133193 times.
✓ Branch 2 taken 97390120 times.
✓ Branch 3 taken 5854820047 times.
✓ Branch 4 taken 82048 times.
✓ Branch 5 taken 97308072 times.
54231343360 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2276 {
2277
4/4
✓ Branch 0 taken 92549673 times.
✓ Branch 1 taken 4758399 times.
✓ Branch 2 taken 2425909 times.
✓ Branch 3 taken 90123764 times.
97308072 if(checkmagic && itemtype != itype_magicring)
2278
2/2
✓ Branch 0 taken 90123147 times.
✓ Branch 1 taken 617 times.
90123764 if(!checkmagiccost(i))
2279 617 continue;
2280
6/6
✓ Branch 0 taken 88368295 times.
✓ Branch 1 taken 8939160 times.
✓ Branch 2 taken 1253626 times.
✓ Branch 3 taken 7685534 times.
✓ Branch 4 taken 5007993 times.
✓ Branch 5 taken 3931167 times.
97307455 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3931167 times.
3931167 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2282 3931167 continue;
2283
3/4
✓ Branch 0 taken 86055 times.
✓ Branch 1 taken 93290233 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86055 times.
93376288 if(check_bunny && !checkbunny(i))
2284 86055 continue;
2285
2286
2/2
✓ Branch 0 taken 9055025 times.
✓ Branch 1 taken 84235208 times.
93290233 if(itemsbuf[i].fam_type >= highestlevel)
2287 {
2288 84235208 highestlevel = itemsbuf[i].fam_type;
2289 84235208 result=i;
2290 84235208 }
2291 93290233 }
2292 54227325521 }
2293
2294
4/4
✓ Branch 0 taken 167782541 times.
✓ Branch 1 taken 44058644 times.
✓ Branch 2 taken 79247 times.
✓ Branch 3 taken 167703294 times.
211841185 if(!(jinx_check || check_bunny)) //Can't cache jinx_check/check_bunny
2295 {
2296
2/2
✓ Branch 0 taken 127941515 times.
✓ Branch 1 taken 39761779 times.
167703294 if (use_cost_cache)
2297 {
2298
2/2
✓ Branch 0 taken 112191480 times.
✓ Branch 1 taken 15750035 times.
127941515 if (!checkmagic)
2299 15750035 itemcache[itemtype] = result;
2300
6/6
✓ Branch 0 taken 15750035 times.
✓ Branch 1 taken 112191480 times.
✓ Branch 2 taken 659583 times.
✓ Branch 3 taken 15090452 times.
✓ Branch 4 taken 646954 times.
✓ Branch 5 taken 12629 times.
127941515 if (checkmagic || result < 0 || checkmagiccost(result))
2301 127928886 itemcache_cost[itemtype] = result;
2302 127941515 }
2303 else
2304 {
2305 39761779 itemcache[itemtype] = result;
2306 }
2307 167703294 }
2308 211841185 return result;
2309 2942846398 }
2310
2311 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2312 2899882879 int current_item_id(int itype, bool checkmagic, bool jinx_check, bool check_bunny)
2313 {
2314
2/4
✓ Branch 0 taken 2899882879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2899882879 times.
2899882879 if(itype < 0 || itype >= itype_max) return -1;
2315
1/2
✓ Branch 0 taken 2899882879 times.
✗ Branch 1 not taken.
2899882879 if(game->OverrideItems[itype] > -2)
2316 {
2317 auto ovid = game->OverrideItems[itype];
2318 if(ovid < 0 || ovid >= MAXITEMS)
2319 return -1;
2320 if(itemsbuf[ovid].family == itype)
2321 {
2322 if(itype == itype_magicring)
2323 checkmagic = false;
2324 else if(itype == itype_ring)
2325 checkmagic = true;
2326
2327 if(checkmagic && !checkmagiccost(ovid))
2328 return -1;
2329 if(jinx_check && !(itemsbuf[ovid].flags & ITEM_JINX_IMMUNE)
2330 && (usesSwordJinx(ovid) ? HeroSwordClk() : HeroItemClk()))
2331 return -1;
2332 return ovid;
2333 }
2334 }
2335 2899882879 auto ret = _c_item_id_internal(itype,checkmagic,jinx_check,check_bunny);
2336
2/2
✓ Branch 0 taken 76964731 times.
✓ Branch 1 taken 2822918148 times.
2899882879 if(!jinx_check) //If not already a jinx-immune-only check...
2337 {
2338 //And the player IS jinxed...
2339
4/4
✓ Branch 0 taken 2790712565 times.
✓ Branch 1 taken 32205583 times.
✓ Branch 2 taken 10757936 times.
✓ Branch 3 taken 2779954629 times.
2822918148 if(HeroSwordClk() || HeroItemClk())
2340 {
2341 //Then do a jinx-immune-only check here
2342 42963519 auto ret2 = _c_item_id_internal(itype,checkmagic,true,check_bunny);
2343 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2344 //Should NOT need a compat rule, as this should always return -1 in old quests.
2345
2/2
✓ Branch 0 taken 3272877 times.
✓ Branch 1 taken 39690642 times.
42963519 if(ret2 > -1) return ret2;
2346 39690642 }
2347 2819645271 }
2348 2896610002 return ret;
2349 2899882879 }
2350
2351 46364329 int current_item_power(int itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2352 {
2353 46364329 int result = current_item_id(itemtype, checkmagic, jinx_check, check_bunny);
2354
2/2
✓ Branch 0 taken 26828647 times.
✓ Branch 1 taken 19535682 times.
46364329 return (result<0) ? 0 : itemsbuf[result].power;
2355 }
2356
2357 26 int32_t heart_container_id()
2358 {
2359
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 for(int32_t i=0; i<MAXITEMS; i++)
2360 {
2361
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 728 times.
754 if(itemsbuf[i].family == itype_heartcontainer)
2362 {
2363 26 return i;
2364 }
2365 728 }
2366 return -1;
2367 26 }
2368
2369 struct tilemod_cache_state_t
2370 {
2371
6/6
✓ Branch 0 taken 4363464 times.
✓ Branch 1 taken 8415849 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8415847 times.
✓ Branch 4 taken 353 times.
✓ Branch 5 taken 8415494 times.
21195162 bool operator==(const tilemod_cache_state_t&) const = default;
2372
2373 bool valid;
2374 bool bunny_clock;
2375 bool superman;
2376 int shield;
2377 };
2378 tilemod_cache_state_t tilemod_cache_state;
2379 int32_t tilemod_cache_value;
2380
2381 6556339 void cache_tile_mod_clear()
2382 {
2383 6556339 tilemod_cache_state = {false};
2384 6556339 }
2385
2386 12779313 int32_t item_tile_mod()
2387 {
2388 51117252 tilemod_cache_state_t state = {
2389 .valid = true,
2390 12779313 .bunny_clock = Hero.BunnyClock() != 0,
2391 12779313 .superman = Hero.superman,
2392 12779313 .shield = Hero.active_shield_id,
2393 };
2394
2/2
✓ Branch 0 taken 8415494 times.
✓ Branch 1 taken 4363819 times.
12779313 if (tilemod_cache_state == state)
2395 8415494 return tilemod_cache_value;
2396
2397 4363819 int32_t tile=0;
2398 4363819 bool check_bombcost = !get_qr(qr_BROKEN_BOMB_AMMO_COSTS);
2399
4/4
✓ Branch 0 taken 3950582 times.
✓ Branch 1 taken 413237 times.
✓ Branch 2 taken 3031303 times.
✓ Branch 3 taken 919279 times.
4363819 if(check_bombcost || game->get_bombs())
2400 {
2401 3444540 int32_t itemid = current_item_id(itype_bomb,check_bombcost);
2402
3/4
✓ Branch 0 taken 3385067 times.
✓ Branch 1 taken 59473 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3385067 times.
3444540 if(itemid > -1 && checkbunny(itemid))
2403 3385067 tile+=itemsbuf[itemid].ltm;
2404 3444540 }
2405
2406
4/4
✓ Branch 0 taken 3950582 times.
✓ Branch 1 taken 413237 times.
✓ Branch 2 taken 928295 times.
✓ Branch 3 taken 3022287 times.
4363819 if(check_bombcost || game->get_sbombs())
2407 {
2408 1341532 int32_t itemid = current_item_id(itype_sbomb,check_bombcost);
2409
3/4
✓ Branch 0 taken 928054 times.
✓ Branch 1 taken 413478 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 928054 times.
1341532 if(itemid > -1 && checkbunny(itemid))
2410 928054 tile+=itemsbuf[itemid].ltm;
2411 1341532 }
2412
2413
2/2
✓ Branch 0 taken 4359216 times.
✓ Branch 1 taken 4603 times.
4363819 if(current_item(itype_clock))
2414 {
2415 4603 int32_t itemid =
2416
2/2
✓ Branch 0 taken 4594 times.
✓ Branch 1 taken 9 times.
4603 get_qr(qr_HARDCODED_LITEM_LTMS)
2417 ? iClock
2418 9 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2419
2/4
✓ Branch 0 taken 4603 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4603 times.
4603 if(itemid > -1 && checkbunny(itemid))
2420 4603 tile+=itemsbuf[itemid].ltm;
2421 4603 }
2422
2423
2/2
✓ Branch 0 taken 3755178 times.
✓ Branch 1 taken 608641 times.
4363819 if(current_item(itype_key))
2424 {
2425 608641 int32_t itemid =
2426
1/2
✓ Branch 0 taken 608641 times.
✗ Branch 1 not taken.
608641 get_qr(qr_HARDCODED_LITEM_LTMS)
2427 ? iKey
2428 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2429
2/4
✓ Branch 0 taken 608641 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 608641 times.
608641 if(itemid > -1 && checkbunny(itemid))
2430 608641 tile+=itemsbuf[itemid].ltm;
2431 608641 }
2432
2433
2/2
✓ Branch 0 taken 3862959 times.
✓ Branch 1 taken 500860 times.
4363819 if(current_item(itype_lkey))
2434 {
2435 500860 int32_t itemid =
2436
2/2
✓ Branch 0 taken 414146 times.
✓ Branch 1 taken 86714 times.
500860 get_qr(qr_HARDCODED_LITEM_LTMS)
2437 ? iLevelKey
2438 86714 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2439
2/4
✓ Branch 0 taken 500860 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500860 times.
500860 if(itemid > -1 && checkbunny(itemid))
2440 500860 tile+=itemsbuf[itemid].ltm;
2441 500860 }
2442
2443
2/2
✓ Branch 0 taken 1529350 times.
✓ Branch 1 taken 2834469 times.
4363819 if(current_item(itype_map))
2444 {
2445 2834469 int32_t itemid =
2446
2/2
✓ Branch 0 taken 2823835 times.
✓ Branch 1 taken 10634 times.
2834469 get_qr(qr_HARDCODED_LITEM_LTMS)
2447 ? iMap
2448 10634 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2449
2/4
✓ Branch 0 taken 2834469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2834469 times.
2834469 if(itemid > -1 && checkbunny(itemid))
2450 2834469 tile+=itemsbuf[itemid].ltm;
2451 2834469 }
2452
2453
2/2
✓ Branch 0 taken 2051829 times.
✓ Branch 1 taken 2311990 times.
4363819 if(current_item(itype_compass))
2454 {
2455 2311990 int32_t itemid =
2456
2/2
✓ Branch 0 taken 2295942 times.
✓ Branch 1 taken 16048 times.
2311990 get_qr(qr_HARDCODED_LITEM_LTMS)
2457 ? iCompass
2458 16048 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2459
2/4
✓ Branch 0 taken 2311990 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2311990 times.
2311990 if(itemid > -1 && checkbunny(itemid))
2460 2311990 tile+=itemsbuf[itemid].ltm;
2461 2311990 }
2462
2463
2/2
✓ Branch 0 taken 1277403 times.
✓ Branch 1 taken 3086416 times.
4363819 if(current_item(itype_bosskey))
2464 {
2465 3086416 int32_t itemid =
2466
2/2
✓ Branch 0 taken 2993139 times.
✓ Branch 1 taken 93277 times.
3086416 get_qr(qr_HARDCODED_LITEM_LTMS)
2467 ? iBossKey
2468 93277 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2469
2/4
✓ Branch 0 taken 3086416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3086416 times.
3086416 if(itemid > -1 && checkbunny(itemid))
2470 3086416 tile+=itemsbuf[itemid].ltm;
2471 3086416 }
2472
2473
2/2
✓ Branch 0 taken 48263 times.
✓ Branch 1 taken 4315556 times.
4363819 if(current_item(itype_magiccontainer))
2474 {
2475 4315556 int32_t itemid =
2476
2/2
✓ Branch 0 taken 3884757 times.
✓ Branch 1 taken 430799 times.
4315556 get_qr(qr_HARDCODED_LITEM_LTMS)
2477 ? iMagicC
2478 430799 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2479
3/4
✓ Branch 0 taken 4315556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 4315539 times.
4315556 if(itemid > -1 && checkbunny(itemid))
2480 4315539 tile+=itemsbuf[itemid].ltm;
2481 4315556 }
2482
2483
2/2
✓ Branch 0 taken 1294632 times.
✓ Branch 1 taken 3069187 times.
4363819 if(current_item(itype_triforcepiece))
2484 {
2485 3069187 int32_t itemid =
2486
1/2
✓ Branch 0 taken 3069187 times.
✗ Branch 1 not taken.
3069187 get_qr(qr_HARDCODED_LITEM_LTMS)
2487 ? iTriforce
2488 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2489
2/4
✓ Branch 0 taken 3069187 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3069187 times.
3069187 if(itemid > -1 && checkbunny(itemid))
2490 3069187 tile+=itemsbuf[itemid].ltm;
2491 3069187 }
2492
2493
2/2
✓ Branch 0 taken 2234275328 times.
✓ Branch 1 taken 4363819 times.
2238639147 for(int32_t i=0; i<itype_max; i++)
2494 {
2495
2/2
✓ Branch 0 taken 2013598720 times.
✓ Branch 1 taken 220676608 times.
2234275328 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2496 {
2497
2/2
✓ Branch 0 taken 4310090 times.
✓ Branch 1 taken 216366518 times.
220676608 switch(i)
2498 {
2499 case itype_bomb:
2500 case itype_sbomb:
2501 case itype_clock:
2502 case itype_key:
2503 case itype_lkey:
2504 case itype_map:
2505 case itype_compass:
2506 case itype_bosskey:
2507 case itype_magiccontainer:
2508 case itype_triforcepiece:
2509 4310090 continue; //already handled
2510 }
2511 216366518 }
2512 2229965238 int32_t itemid = current_item_id(i,false);
2513
2/2
✓ Branch 0 taken 2225601419 times.
✓ Branch 1 taken 4363819 times.
2229965238 if(i == itype_shield)
2514 4363819 itemid = getCurrentShield(false);
2515
2516
4/4
✓ Branch 0 taken 113997092 times.
✓ Branch 1 taken 2115968146 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 113997091 times.
2229965238 if(itemid < 0 || !checkbunny(itemid))
2517 2115968147 continue;
2518
2519 113997091 itemdata const& itm = itemsbuf[itemid];
2520
2521
2/2
✓ Branch 0 taken 110334468 times.
✓ Branch 1 taken 3662623 times.
113997091 switch(itm.family)
2522 {
2523 case itype_shield:
2524
1/2
✓ Branch 0 taken 3662623 times.
✗ Branch 1 not taken.
3662623 if(itm.flags & ITEM_FLAG9) //active shield
2525 {
2526 if(!usingActiveShield(itemid))
2527 {
2528 tile+=itm.misc6; //'Inactive PTM'
2529 continue;
2530 }
2531 }
2532 3662623 break;
2533 }
2534
2535 113997091 tile+=itm.ltm;
2536 113997091 }
2537
2538 4363819 tilemod_cache_value = tile;
2539 4363819 tilemod_cache_state = state;
2540 4363819 return tile;
2541 12779313 }
2542
2543 12779313 int32_t bunny_tile_mod()
2544 {
2545
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 12777443 times.
12779313 if(Hero.BunnyClock())
2546 {
2547 1870 return game->get_bunny_ltm();
2548 }
2549 12777443 return 0;
2550 12779313 }
2551
2552 // Hints are drawn on a separate layer to combo reveals.
2553 20010 void draw_lens_under(BITMAP *dest, bool layer)
2554 {
2555 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2556 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2557 //Lens flag 3: Don't show armos/chest/dive items
2558 //Lens flag 4: Show Raft Paths
2559 //Lens flag 5: Show Invisible Enemies
2560
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 19554 times.
✓ Branch 2 taken 9777 times.
✓ Branch 3 taken 9777 times.
20010 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2561
2562 20010 int32_t strike_hint_table[11]=
2563 {
2564 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2565 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2566 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2567 };
2568
2569 // int32_t page = tmpscr->cpage;
2570 {
2571 20010 int32_t blink_rate=flash_reduction_enabled()?6:1;
2572 // int32_t temptimer=0;
2573 20010 int32_t tempitem, tempweapon=0;
2574 20010 strike_hint=strike_hint_table[strike_hint_counter];
2575
2576
2/2
✓ Branch 0 taken 19412 times.
✓ Branch 1 taken 598 times.
20010 if(strike_hint_timer>32)
2577 {
2578 598 strike_hint_timer=0;
2579 598 strike_hint_counter=((strike_hint_counter+1)%11);
2580 598 }
2581
2582 20010 ++strike_hint_timer;
2583
2584
2/2
✓ Branch 0 taken 3521760 times.
✓ Branch 1 taken 20010 times.
3541770 for(int32_t i=0; i<176; i++)
2585 {
2586 3521760 int32_t x = (i & 15) << 4;
2587 3521760 int32_t y = (i & 0xF0) + playing_field_offset;
2588 3521760 int32_t tempitemx=-16, tempitemy=-16;
2589 3521760 int32_t tempweaponx=-16, tempweapony=-16;
2590
2591
2/2
✓ Branch 0 taken 7043520 times.
✓ Branch 1 taken 3521760 times.
10565280 for(int32_t iter=0; iter<2; ++iter)
2592 {
2593 7043520 int32_t checkflag=0;
2594
2595
2/2
✓ Branch 0 taken 3521760 times.
✓ Branch 1 taken 3521760 times.
7043520 if(iter==0)
2596 {
2597 3521760 checkflag=combobuf[tmpscr->data[i]].flag;
2598 3521760 }
2599 else
2600 {
2601 3521760 checkflag=tmpscr->sflag[i];
2602 }
2603
2604
2/2
✓ Branch 0 taken 7042422 times.
✓ Branch 1 taken 1098 times.
7043520 if(checkflag==mfSTRIKE)
2605 {
2606
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2607 {
2608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2609 906 }
2610 else
2611 {
2612 192 checkflag = strike_hint;
2613 }
2614 1098 }
2615
2616
21/36
✓ Branch 0 taken 6894870 times.
✓ Branch 1 taken 3258 times.
✓ Branch 2 taken 108898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2602 times.
✓ Branch 5 taken 28750 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 93 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 25 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 138 times.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
7043520 switch(checkflag)
2617 {
2618 case 0:
2619 case mfZELDA:
2620 case mfPUSHED:
2621 case mfENEMY0:
2622 case mfENEMY1:
2623 case mfENEMY2:
2624 case mfENEMY3:
2625 case mfENEMY4:
2626 case mfENEMY5:
2627 case mfENEMY6:
2628 case mfENEMY7:
2629 case mfENEMY8:
2630 case mfENEMY9:
2631 case mfSINGLE:
2632 case mfSINGLE16:
2633 case mfNOENEMY:
2634 case mfTRAP_H:
2635 case mfTRAP_V:
2636 case mfTRAP_4:
2637 case mfTRAP_LR:
2638 case mfTRAP_UD:
2639 case mfNOGROUNDENEMY:
2640 case mfNOBLOCKS:
2641 case mfSCRIPT1:
2642 case mfSCRIPT2:
2643 case mfSCRIPT3:
2644 case mfSCRIPT4:
2645 case mfSCRIPT5:
2646 case mfSCRIPT6:
2647 case mfSCRIPT7:
2648 case mfSCRIPT8:
2649 case mfSCRIPT9:
2650 case mfSCRIPT10:
2651 case mfSCRIPT11:
2652 case mfSCRIPT12:
2653 case mfSCRIPT13:
2654 case mfSCRIPT14:
2655 case mfSCRIPT15:
2656 case mfSCRIPT16:
2657 case mfSCRIPT17:
2658 case mfSCRIPT18:
2659 case mfSCRIPT19:
2660 case mfSCRIPT20:
2661 case mfPITHOLE:
2662 case mfPITFALLFLOOR:
2663 case mfLAVA:
2664 case mfICE:
2665 case mfICEDAMAGE:
2666 case mfDAMAGE1:
2667 case mfDAMAGE2:
2668 case mfDAMAGE4:
2669 case mfDAMAGE8:
2670 case mfDAMAGE16:
2671 case mfDAMAGE32:
2672 case mfFREEZEALL:
2673 case mfFREZEALLANSFFCS:
2674 case mfFREEZEFFCSOLY:
2675 case mfSCRITPTW1TRIG:
2676 case mfSCRITPTW2TRIG:
2677 case mfSCRITPTW3TRIG:
2678 case mfSCRITPTW4TRIG:
2679 case mfSCRITPTW5TRIG:
2680 case mfSCRITPTW6TRIG:
2681 case mfSCRITPTW7TRIG:
2682 case mfSCRITPTW8TRIG:
2683 case mfSCRITPTW9TRIG:
2684 case mfSCRITPTW10TRIG:
2685 case mfTROWEL:
2686 case mfTROWELNEXT:
2687 case mfTROWELSPECIALITEM:
2688 case mfSLASHPOT:
2689 case mfLIFTPOT:
2690 case mfLIFTORSLASH:
2691 case mfLIFTROCK:
2692 case mfLIFTROCKHEAVY:
2693 case mfDROPITEM:
2694 case mfSPECIALITEM:
2695 case mfDROPKEY:
2696 case mfDROPLKEY:
2697 case mfDROPCOMPASS:
2698 case mfDROPMAP:
2699 case mfDROPBOSSKEY:
2700 case mfSPAWNNPC:
2701 case mfSWITCHHOOK:
2702 case mfSIDEVIEWLADDER:
2703 case mfSIDEVIEWPLATFORM:
2704 case mfNOENEMYSPAWN:
2705 case mfENEMYALL:
2706 case mfNOMIRROR:
2707 case mfUNSAFEGROUND:
2708 case mf168:
2709 case mf169:
2710 case mf170:
2711 case mf171:
2712 case mf172:
2713 case mf173:
2714 case mf174:
2715 case mf175:
2716 case mf176:
2717 case mf177:
2718 case mf178:
2719 case mf179:
2720 case mf180:
2721 case mf181:
2722 case mf182:
2723 case mf183:
2724 case mf184:
2725 case mf185:
2726 case mf186:
2727 case mf187:
2728 case mf188:
2729 case mf189:
2730 case mf190:
2731 case mf191:
2732 case mf192:
2733 case mf193:
2734 case mf194:
2735 case mf195:
2736 case mf196:
2737 case mf197:
2738 case mf198:
2739 case mf199:
2740 case mf200:
2741 case mf201:
2742 case mf202:
2743 case mf203:
2744 case mf204:
2745 case mf205:
2746 case mf206:
2747 case mf207:
2748 case mf208:
2749 case mf209:
2750 case mf210:
2751 case mf211:
2752 case mf212:
2753 case mf213:
2754 case mf214:
2755 case mf215:
2756 case mf216:
2757 case mf217:
2758 case mf218:
2759 case mf219:
2760 case mf220:
2761 case mf221:
2762 case mf222:
2763 case mf223:
2764 case mf224:
2765 case mf225:
2766 case mf226:
2767 case mf227:
2768 case mf228:
2769 case mf229:
2770 case mf230:
2771 case mf231:
2772 case mf232:
2773 case mf233:
2774 case mf234:
2775 case mf235:
2776 case mf236:
2777 case mf237:
2778 case mf238:
2779 case mf239:
2780 case mf240:
2781 case mf241:
2782 case mf242:
2783 case mf243:
2784 case mf244:
2785 case mf245:
2786 case mf246:
2787 case mf247:
2788 case mf248:
2789 case mf249:
2790 case mf250:
2791 case mf251:
2792 case mf252:
2793 case mf253:
2794 case mf254:
2795 case mfEXTENDED:
2796 6894870 break;
2797
2798 case mfPUSHUD:
2799 case mfPUSHLR:
2800 case mfPUSH4:
2801 case mfPUSHU:
2802 case mfPUSHD:
2803 case mfPUSHL:
2804 case mfPUSHR:
2805 case mfPUSHUDNS:
2806 case mfPUSHLRNS:
2807 case mfPUSH4NS:
2808 case mfPUSHUNS:
2809 case mfPUSHDNS:
2810 case mfPUSHLNS:
2811 case mfPUSHRNS:
2812 case mfPUSHUDINS:
2813 case mfPUSHLRINS:
2814 case mfPUSH4INS:
2815 case mfPUSHUINS:
2816 case mfPUSHDINS:
2817 case mfPUSHLINS:
2818 case mfPUSHRINS:
2819
3/4
✓ Branch 0 taken 1939 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1939 times.
3258 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2820
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1939 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1939 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1939 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2821 {
2822 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2823 }
2824
2825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
3258 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2826
3/6
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 738 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 738 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3258 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2827 {
2828
2/2
✓ Branch 0 taken 1488 times.
✓ Branch 1 taken 1032 times.
2520 if(hints)
2829 {
2830
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2831 {
2832 case cPUSH_HEAVY:
2833 case cPUSH_HW:
2834 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2835 72 tempitemx=x, tempitemy=y;
2836
2837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2838 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2839
2840 72 break;
2841
2842 case cPUSH_HEAVY2:
2843 case cPUSH_HW2:
2844 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2845 63 tempitemx=x, tempitemy=y;
2846
2847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2848 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2849
2850 63 break;
2851 }
2852 1032 }
2853 2520 }
2854
2855 3258 break;
2856
2857 case mfWHISTLE:
2858
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2859 {
2860 tempitem=getItemID(itemsbuf,itype_whistle,1);
2861
2862 if(tempitem<0) break;
2863
2864 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2865 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2866 {
2867 tempitemx=x;
2868 tempitemy=y;
2869 }
2870
2871 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2872 }
2873
2874 2418 break;
2875
2876 //Why is this here?
2877 case mfFAIRY:
2878 case mfMAGICFAIRY:
2879 case mfALLFAIRY:
2880 if(hints)
2881 {
2882 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2883
2884 if(tempitem < 0) break;
2885
2886 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2887 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2888 {
2889 tempitemx=x;
2890 tempitemy=y;
2891 }
2892
2893 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2894 }
2895
2896 break;
2897
2898 case mfANYFIRE:
2899
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2900 {
2901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2902 252 }
2903 else
2904 {
2905 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2906
2907
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2908
2909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2910
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2911 {
2912 189 tempitemx=x;
2913 189 tempitemy=y;
2914 189 }
2915
2916 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2917 }
2918
2919 504 break;
2920
2921 case mfSTRONGFIRE:
2922 if(!hints)
2923 {
2924 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2925 }
2926 else
2927 {
2928 tempitem=getItemID(itemsbuf,itype_candle,2);
2929
2930 if(tempitem<0) break;
2931
2932 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2933 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2934 {
2935 tempitemx=x;
2936 tempitemy=y;
2937 }
2938
2939 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2940 }
2941
2942 break;
2943
2944 case mfMAGICFIRE:
2945 if(!hints)
2946 {
2947 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2948 }
2949 else
2950 {
2951 tempitem=getItemID(itemsbuf,itype_wand,1);
2952
2953 if(tempitem<0) break;
2954
2955 tempweapon=wFire;
2956
2957 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2958 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2959 {
2960 tempitemx=x;
2961 tempitemy=y;
2962 }
2963 else
2964 {
2965 tempweaponx=x;
2966 tempweapony=y;
2967 }
2968
2969 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2970 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2971 }
2972
2973 break;
2974
2975 case mfDIVINEFIRE:
2976 if(!hints)
2977 {
2978 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2979 }
2980 else
2981 {
2982 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2983
2984 if(tempitem<0) break;
2985
2986 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2987 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2988 {
2989 tempitemx=x;
2990 tempitemy=y;
2991 }
2992
2993 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2994 }
2995
2996 break;
2997
2998 case mfARROW:
2999
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
3000 {
3001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
3002 732 }
3003 else
3004 {
3005 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
3006
3007
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
3008
3009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3010
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3011 {
3012 61 tempitemx=x;
3013 61 tempitemy=y;
3014 61 }
3015
3016 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3017 }
3018
3019 814 break;
3020
3021 case mfSARROW:
3022 if(!hints)
3023 {
3024 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3025 }
3026 else
3027 {
3028 tempitem=getItemID(itemsbuf,itype_arrow,2);
3029
3030 if(tempitem<0) break;
3031
3032 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3033 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3034 {
3035 tempitemx=x;
3036 tempitemy=y;
3037 }
3038
3039 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3040 }
3041
3042 break;
3043
3044 case mfGARROW:
3045 if(!hints)
3046 {
3047 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3048 }
3049 else
3050 {
3051 tempitem=getItemID(itemsbuf,itype_arrow,3);
3052
3053 if(tempitem<0) break;
3054
3055 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3056 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3057 {
3058 tempitemx=x;
3059 tempitemy=y;
3060 }
3061
3062 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3063 }
3064
3065 break;
3066
3067 case mfBOMB:
3068
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 76 times.
93 if(!hints)
3069 {
3070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3071 76 }
3072 else
3073 {
3074 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3075 17 tempweapon = wLitBomb;
3076
3077 //if (tempitem<0) break;
3078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3079
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3080 {
3081 12 tempweaponx=x;
3082 12 tempweapony=y;
3083 12 }
3084
3085 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3086 }
3087
3088 93 break;
3089
3090 case mfSBOMB:
3091
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3092 {
3093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3094 48 }
3095 else
3096 {
3097 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3098 //if (tempitem<0) break;
3099 48 tempweapon = wLitSBomb;
3100
3101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3102
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3103 {
3104 36 tempweaponx=x;
3105 36 tempweapony=y;
3106 36 }
3107
3108 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3109 }
3110
3111 96 break;
3112
3113 case mfARMOS_SECRET:
3114
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3115 {
3116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3117 12 }
3118 24 break;
3119
3120 case mfBRANG:
3121
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 if(!hints)
3122 {
3123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3124 20 }
3125 else
3126 {
3127 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3128
3129
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3130
3131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3132
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3133 {
3134 4 tempitemx=x;
3135 4 tempitemy=y;
3136 4 }
3137
3138 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3139 }
3140
3141 25 break;
3142
3143 case mfMBRANG:
3144 if(!hints)
3145 {
3146 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3147 }
3148 else
3149 {
3150 tempitem=getItemID(itemsbuf,itype_brang,2);
3151
3152 if(tempitem<0) break;
3153
3154 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3155 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3156 {
3157 tempitemx=x;
3158 tempitemy=y;
3159 }
3160
3161 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3162 }
3163
3164 break;
3165
3166 case mfFBRANG:
3167 if(!hints)
3168 {
3169 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3170 }
3171 else
3172 {
3173 tempitem=getItemID(itemsbuf,itype_brang,3);
3174
3175 if(tempitem<0) break;
3176
3177 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3178 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3179 {
3180 tempitemx=x;
3181 tempitemy=y;
3182 }
3183
3184 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3185 }
3186
3187 break;
3188
3189 case mfWANDMAGIC:
3190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(!hints)
3191 {
3192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3193 138 }
3194 else
3195 {
3196 tempitem=getItemID(itemsbuf,itype_wand,1);
3197
3198 if(tempitem<0) break;
3199
3200 tempweapon=itemsbuf[tempitem].wpn3;
3201
3202 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3203 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3204 {
3205 tempitemx=x;
3206 tempitemy=y;
3207 }
3208 else
3209 {
3210 tempweaponx=x;
3211 tempweapony=y;
3212 --lens_hint_weapon[wMagic][4];
3213
3214 if(lens_hint_weapon[wMagic][4]<-8)
3215 {
3216 lens_hint_weapon[wMagic][4]=8;
3217 }
3218 }
3219
3220 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3221 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3222 }
3223
3224 138 break;
3225
3226 case mfREFMAGIC:
3227
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3228 {
3229 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3230 }
3231 else
3232 {
3233 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3234
3235
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3236
3237 16 tempweapon=ewMagic;
3238
3239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3240
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3241 {
3242 13 tempitemx=x;
3243 13 tempitemy=y;
3244 13 }
3245 else
3246 {
3247 3 tempweaponx=x;
3248 3 tempweapony=y;
3249
3250
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3251 {
3252 1 --lens_hint_weapon[ewMagic][4];
3253 1 }
3254 else
3255 {
3256 2 ++lens_hint_weapon[ewMagic][4];
3257 }
3258
3259
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3260 {
3261 lens_hint_weapon[ewMagic][2]=up;
3262 }
3263
3264
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3265 {
3266 2 lens_hint_weapon[ewMagic][2]=down;
3267 2 }
3268 }
3269
3270 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3271 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3272 }
3273
3274 16 break;
3275
3276 case mfREFFIREBALL:
3277
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3278 {
3279 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3280 }
3281 else
3282 {
3283 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3284
3285
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3286
3287 16 tempweapon=ewFireball;
3288
3289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3290
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3291 {
3292 12 tempitemx=x;
3293 12 tempitemy=y;
3294 12 tempweaponx=x;
3295 12 tempweapony=y;
3296 12 ++lens_hint_weapon[ewFireball][3];
3297
3298
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3299 {
3300 1 lens_hint_weapon[ewFireball][3]=-8;
3301 1 lens_hint_weapon[ewFireball][4]=8;
3302 1 }
3303
3304
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3305 {
3306 8 ++lens_hint_weapon[ewFireball][4];
3307 8 }
3308 else
3309 {
3310 4 --lens_hint_weapon[ewFireball][4];
3311 }
3312 12 }
3313
3314 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3315 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3316 }
3317
3318 16 break;
3319
3320 case mfSWORD:
3321
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3322 {
3323 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3324 }
3325 else
3326 {
3327 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3328
3329
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3330
3331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3332
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3333 {
3334 5 tempitemx=x;
3335 5 tempitemy=y;
3336 5 }
3337
3338 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3339 }
3340
3341 7 break;
3342
3343 case mfWSWORD:
3344 if(!hints)
3345 {
3346 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3347 }
3348 else
3349 {
3350 tempitem=getItemID(itemsbuf,itype_sword,2);
3351
3352 if(tempitem<0) break;
3353
3354 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3355 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3356 {
3357 tempitemx=x;
3358 tempitemy=y;
3359 }
3360
3361 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3362 }
3363
3364 break;
3365
3366 case mfMSWORD:
3367 if(!hints)
3368 {
3369 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3370 }
3371 else
3372 {
3373 tempitem=getItemID(itemsbuf,itype_sword,3);
3374
3375 if(tempitem<0) break;
3376
3377 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3378 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3379 {
3380 tempitemx=x;
3381 tempitemy=y;
3382 }
3383
3384 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3385 }
3386
3387 break;
3388
3389 case mfXSWORD:
3390 if(!hints)
3391 {
3392 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3393 }
3394 else
3395 {
3396 tempitem=getItemID(itemsbuf,itype_sword,4);
3397
3398 if(tempitem<0) break;
3399
3400 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3401 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3402 {
3403 tempitemx=x;
3404 tempitemy=y;
3405 }
3406
3407 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3408 }
3409
3410 break;
3411
3412 case mfSWORDBEAM:
3413
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3414 {
3415 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3416 }
3417 else
3418 {
3419 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3420
3421
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3422
3423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3424
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3425 {
3426 11 tempitemx=x;
3427 11 tempitemy=y;
3428 11 }
3429
3430 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3431 }
3432
3433 16 break;
3434
3435 case mfWSWORDBEAM:
3436 if(!hints)
3437 {
3438 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3439 }
3440 else
3441 {
3442 tempitem=getItemID(itemsbuf,itype_sword,2);
3443
3444 if(tempitem<0) break;
3445
3446 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3447 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3448 {
3449 tempitemx=x;
3450 tempitemy=y;
3451 }
3452
3453 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3454 }
3455
3456 break;
3457
3458 case mfMSWORDBEAM:
3459 if(!hints)
3460 {
3461 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3462 }
3463 else
3464 {
3465 tempitem=getItemID(itemsbuf,itype_sword,3);
3466
3467 if(tempitem<0) break;
3468
3469 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3470 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3471 {
3472 tempitemx=x;
3473 tempitemy=y;
3474 }
3475
3476 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3477 }
3478
3479 break;
3480
3481 case mfXSWORDBEAM:
3482 if(!hints)
3483 {
3484 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3485 }
3486 else
3487 {
3488 tempitem=getItemID(itemsbuf,itype_sword,4);
3489
3490 if(tempitem<0) break;
3491
3492 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3493 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3494 {
3495 tempitemx=x;
3496 tempitemy=y;
3497 }
3498
3499 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3500 }
3501
3502 break;
3503
3504 case mfHOOKSHOT:
3505
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3506 {
3507 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3508 }
3509 else
3510 {
3511 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3512
3513
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3514
3515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3516
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3517 {
3518 12 tempitemx=x;
3519 12 tempitemy=y;
3520 12 }
3521
3522 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3523 }
3524
3525 17 break;
3526
3527 case mfWAND:
3528
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3529 {
3530 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3531 }
3532 else
3533 {
3534 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3535
3536
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3537
3538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3539
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3540 {
3541 28 tempitemx=x;
3542 28 tempitemy=y;
3543 28 }
3544
3545 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3546 }
3547
3548 35 break;
3549
3550 case mfHAMMER:
3551
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3552 {
3553 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3554 }
3555 else
3556 {
3557 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3558
3559
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3560
3561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3562
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3563 {
3564 13 tempitemx=x;
3565 13 tempitemy=y;
3566 13 }
3567
3568 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3569 }
3570
3571 17 break;
3572
3573 case mfARMOS_ITEM:
3574 case mfDIVE_ITEM:
3575
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2602 times.
2602 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3576 {
3577 2602 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3578 2602 }
3579 2602 break;
3580
3581 case 16:
3582 case 17:
3583 case 18:
3584 case 19:
3585 case 20:
3586 case 21:
3587 case 22:
3588 case 23:
3589 case 24:
3590 case 25:
3591 case 26:
3592 case 27:
3593 case 28:
3594 case 29:
3595 case 30:
3596 case 31:
3597
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 107890 times.
108898 if(!hints)
3598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107890 times.
215780 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3599 107890 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3600
3601 108898 break;
3602 case mfSECRETSNEXT:
3603 if(!hints)
3604 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3605 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3606
3607 break;
3608
3609 case mfSTRIKE:
3610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3611 {
3612 906 goto special;
3613 }
3614 else
3615 {
3616 break;
3617 }
3618
3619 28750 default: goto special;
3620
3621 special:
3622
8/8
✓ Branch 0 taken 14732 times.
✓ Branch 1 taken 14924 times.
✓ Branch 2 taken 528 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 496 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29656 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3623 {
3624
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6604 times.
✓ Branch 2 taken 4954 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1650 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6604 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3625 {
3626 4954 rectfill(dest,x,y,x+15,y+15,WHITE);
3627 4954 }
3628 6604 }
3629
3630 29656 break;
3631 }
3632 7043520 }
3633 3521760 }
3634
3635
2/2
✓ Branch 0 taken 10005 times.
✓ Branch 1 taken 10005 times.
20010 if(layer)
3636 {
3637
2/2
✓ Branch 0 taken 9646 times.
✓ Branch 1 taken 359 times.
10005 if(tmpscr->door[0]==dWALK)
3638 359 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3639
3640
2/2
✓ Branch 0 taken 9582 times.
✓ Branch 1 taken 423 times.
10005 if(tmpscr->door[1]==dWALK)
3641 423 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3642
3643
2/2
✓ Branch 0 taken 9423 times.
✓ Branch 1 taken 582 times.
10005 if(tmpscr->door[2]==dWALK)
3644 582 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3645
3646
2/2
✓ Branch 0 taken 9381 times.
✓ Branch 1 taken 624 times.
10005 if(tmpscr->door[3]==dWALK)
3647 624 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3648
3649
2/2
✓ Branch 0 taken 9962 times.
✓ Branch 1 taken 43 times.
10005 if(tmpscr->door[0]==dBOMB)
3650 {
3651 43 showbombeddoor(dest, 0);
3652 43 }
3653
3654
2/2
✓ Branch 0 taken 9966 times.
✓ Branch 1 taken 39 times.
10005 if(tmpscr->door[1]==dBOMB)
3655 {
3656 39 showbombeddoor(dest, 1);
3657 39 }
3658
3659
2/2
✓ Branch 0 taken 9999 times.
✓ Branch 1 taken 6 times.
10005 if(tmpscr->door[2]==dBOMB)
3660 {
3661 6 showbombeddoor(dest, 2);
3662 6 }
3663
3664
2/2
✓ Branch 0 taken 9968 times.
✓ Branch 1 taken 37 times.
10005 if(tmpscr->door[3]==dBOMB)
3665 {
3666 37 showbombeddoor(dest, 3);
3667 37 }
3668 10005 }
3669
3670
2/2
✓ Branch 0 taken 17976 times.
✓ Branch 1 taken 2034 times.
20010 if(tmpscr->stairx + tmpscr->stairy)
3671 {
3672
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3673 {
3674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3675 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3676 1123 }
3677 else
3678 {
3679
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3680 {
3681 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3682 48 int32_t tempitemx=-16;
3683 48 int32_t tempitemy=-16;
3684
3685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3686
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3687 {
3688 24 tempitemx=tmpscr->stairx;
3689 24 tempitemy=tmpscr->stairy+playing_field_offset;
3690 24 }
3691
3692 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3693 48 }
3694 }
3695 2034 }
3696 }
3697 20010 }
3698
3699 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3700
3701 9666 void draw_lens_over()
3702 {
3703 // Oh, what the heck.
3704 static BITMAP *lens_scr = NULL;
3705 static int32_t last_width = -1;
3706 9666 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3707
3708 // Only redraw the circle if the size has changed
3709
2/2
✓ Branch 0 taken 9647 times.
✓ Branch 1 taken 19 times.
9666 if(width != last_width)
3710 {
3711
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2 times.
19 if(lens_scr == NULL)
3712 {
3713 17 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3714 17 }
3715
3716 19 clear_to_color(lens_scr, BLACK);
3717 19 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3718 19 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3719 19 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3720 19 last_width=width;
3721 19 }
3722
3723 9666 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3724 9666 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3725 9666 }
3726
3727 //----------------------------------------------------------------
3728
3729 31797 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3730 {
3731 //recreating a big bitmap every frame is highly sluggish.
3732
4/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 31792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
31797 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3733 31797 clear_to_color(wavebuf, BLACK);
3734 31797 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3735
3736 int32_t ofs;
3737 // int32_t amplitude=8;
3738 // int32_t wavelength=4;
3739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31797 times.
31797 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3740
4/6
✓ Branch 0 taken 31797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31797 times.
✓ Branch 4 taken 494 times.
✓ Branch 5 taken 31303 times.
31797 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3741 31797 int32_t amp2=168;
3742
2/4
✓ Branch 0 taken 31797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31797 times.
31797 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3743 31797 int32_t i=frame%amp2;
3744
3745
2/2
✓ Branch 0 taken 5341896 times.
✓ Branch 1 taken 31797 times.
5373693 for(int32_t j=0; j<168; j++)
3746 {
3747
3/4
✓ Branch 0 taken 2670948 times.
✓ Branch 1 taken 2670948 times.
✓ Branch 2 taken 2670948 times.
✗ Branch 3 not taken.
5341896 if(j&1 && interpol)
3748 {
3749 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3750 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3751 }
3752 else
3753 {
3754 5341896 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3755 }
3756
3757
1/2
✓ Branch 0 taken 5341896 times.
✗ Branch 1 not taken.
5341896 if(ofs)
3758 {
3759
2/2
✓ Branch 0 taken 1367525376 times.
✓ Branch 1 taken 5341896 times.
1372867272 for(int32_t k=0; k<256; k++)
3760 {
3761 1367525376 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3762 1367525376 }
3763 5341896 }
3764 5341896 }
3765 31797 }
3766
3767 28224 void draw_fuzzy(int32_t fuzz)
3768 // draws from right half of scrollbuf to framebuf
3769 {
3770 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3771 byte *start, *si, *di;
3772
3773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28224 times.
28224 if(fuzz<1)
3774 fuzz = 1;
3775
3776 28224 xstep = 128%fuzz;
3777
3778
2/2
✓ Branch 0 taken 5880 times.
✓ Branch 1 taken 22344 times.
28224 if(xstep > 0)
3779 22344 xstep = fuzz-xstep;
3780
3781 28224 ystep = 112%fuzz;
3782
3783
2/2
✓ Branch 0 taken 8232 times.
✓ Branch 1 taken 19992 times.
28224 if(ystep > 0)
3784 19992 ystep = fuzz-ystep;
3785
3786 28224 firsty = 1;
3787
3788
2/2
✓ Branch 0 taken 28224 times.
✓ Branch 1 taken 1018416 times.
1046640 for(y=0; y<224;)
3789 {
3790 1018416 start = &(scrollbuf->line[y][256]);
3791
3792
4/4
✓ Branch 0 taken 1004304 times.
✓ Branch 1 taken 6336288 times.
✓ Branch 2 taken 6322176 times.
✓ Branch 3 taken 1018416 times.
7340592 for(dy=0; dy<ystep && dy+y<224; dy++)
3793 {
3794 6322176 si = start;
3795 6322176 di = &(framebuf->line[y+dy][0]);
3796 6322176 i = xstep;
3797 6322176 firstx = 1;
3798
3799
2/2
✓ Branch 0 taken 1618477056 times.
✓ Branch 1 taken 6322176 times.
1624799232 for(dx=0; dx<256; dx++)
3800 {
3801 1618477056 *(di++) = *si;
3802
3803
2/2
✓ Branch 0 taken 1363746048 times.
✓ Branch 1 taken 254731008 times.
1618477056 if(++i >= fuzz)
3804 {
3805
2/2
✓ Branch 0 taken 248408832 times.
✓ Branch 1 taken 6322176 times.
254731008 if(!firstx)
3806 248408832 si += fuzz;
3807 else
3808 {
3809 6322176 si += fuzz-xstep;
3810 6322176 firstx = 0;
3811 }
3812
3813 254731008 i = 0;
3814 254731008 }
3815 1618477056 }
3816 6322176 }
3817
3818
2/2
✓ Branch 0 taken 990192 times.
✓ Branch 1 taken 28224 times.
1018416 if(!firsty)
3819 990192 y += fuzz;
3820 else
3821 {
3822 28224 y += ystep;
3823 28224 ystep = fuzz;
3824 28224 firsty = 0;
3825 }
3826 }
3827 28224 }
3828
3829 18320143 void updatescr(bool allowwavy)
3830 {
3831
4/6
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 18319880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 263 times.
✓ Branch 4 taken 263 times.
✗ Branch 5 not taken.
18320143 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3832
4/6
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 18319880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 263 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 263 times.
18320143 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3833
3834
2/2
✓ Branch 0 taken 18292838 times.
✓ Branch 1 taken 27305 times.
18320143 if(toogam)
3835 {
3836 27305 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3837 27305 }
3838
3839
1/2
✓ Branch 0 taken 18320143 times.
✗ Branch 1 not taken.
18320143 if(Showpal)
3840 dump_pal(framebuf);
3841
3842
2/2
✓ Branch 0 taken 17806834 times.
✓ Branch 1 taken 513309 times.
18320143 if(!Playing)
3843 513309 black_opening_count=0;
3844
3845
2/2
✓ Branch 0 taken 18155658 times.
✓ Branch 1 taken 164485 times.
18320143 if(black_opening_count<0) //shape is opening up
3846 {
3847 164485 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3848
3849
2/4
✓ Branch 0 taken 164485 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 164485 times.
164485 if(Advance||(!Paused))
3850 {
3851 164485 ++black_opening_count;
3852 164485 }
3853 164485 }
3854
2/2
✓ Branch 0 taken 18107676 times.
✓ Branch 1 taken 47982 times.
18155658 else if(black_opening_count>0) //shape is closing
3855 {
3856 47982 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3857
3858
2/4
✓ Branch 0 taken 47982 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47982 times.
47982 if(Advance||(!Paused))
3859 {
3860 47982 --black_opening_count;
3861 47982 }
3862 47982 }
3863
3864
3/4
✓ Branch 0 taken 18110895 times.
✓ Branch 1 taken 209248 times.
✓ Branch 2 taken 18110895 times.
✗ Branch 3 not taken.
18320143 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3865 {
3866 black_opening_shape = bosCIRCLE;
3867 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3868 refreshTints();
3869 refreshpal=true;
3870 }
3871
3872
2/2
✓ Branch 0 taken 17691383 times.
✓ Branch 1 taken 628760 times.
18320143 if(refreshpal)
3873 {
3874 628760 refreshpal=false;
3875 628760 RAMpal[253] = _RGB(0,0,0);
3876 628760 RAMpal[254] = _RGB(63,63,63);
3877 628760 hw_palette = &RAMpal;
3878 628760 update_hw_pal = true;
3879
3880 628760 create_rgb_table(&rgb_table, RAMpal, NULL);
3881 628760 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3882 628760 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3883
3884
2/2
✓ Branch 0 taken 160962560 times.
✓ Branch 1 taken 628760 times.
161591320 for(int32_t q=0; q<PAL_SIZE; q++)
3885 {
3886 160962560 trans_table2.data[0][q] = q;
3887 160962560 trans_table2.data[q][q] = q;
3888 160962560 }
3889 628760 }
3890
3891 18320143 bool clearwavy = (wavy <= 0);
3892
3893
2/2
✓ Branch 0 taken 8341 times.
✓ Branch 1 taken 18311802 times.
18320143 if(wavy <= 0)
3894 {
3895 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3896 18311802 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3897 18311802 }
3898
3899 18320143 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3900
3901
6/6
✓ Branch 0 taken 32047 times.
✓ Branch 1 taken 18288096 times.
✓ Branch 2 taken 31925 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31797 times.
18320143 if(wavy && Playing && allowwavy)
3902 {
3903 31797 draw_wavy(framebuf, wavybuf, wavy,false);
3904 31797 }
3905
3906
2/2
✓ Branch 0 taken 18311802 times.
✓ Branch 1 taken 8341 times.
18320143 if(clearwavy)
3907 18311802 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3908
2/4
✓ Branch 0 taken 8341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8341 times.
8341 else if(Playing && !Paused)
3909 8341 wavy--; // Wavy was set by a script. Decrement it.
3910
3911
5/6
✓ Branch 0 taken 17806834 times.
✓ Branch 1 taken 513309 times.
✓ Branch 2 taken 664395 times.
✓ Branch 3 taken 17142439 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 664395 times.
18320143 if(Playing && msgpos && !screenscrolling)
3912 {
3913
1/2
✓ Branch 0 taken 664395 times.
✗ Branch 1 not taken.
664395 if(!(msg_bg_display_buf->clip))
3914 664395 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3915
1/2
✓ Branch 0 taken 664395 times.
✗ Branch 1 not taken.
664395 if(!(msg_portrait_display_buf->clip))
3916 664395 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3917
1/2
✓ Branch 0 taken 664395 times.
✗ Branch 1 not taken.
664395 if(!(msg_txt_display_buf->clip))
3918 664395 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3919 664395 }
3920
3921 /*
3922 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3923 {
3924 BITMAP* subBmp = 0;
3925 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3926 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3927 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3928 destroy_bitmap(subBmp);
3929 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3930 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3931 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3932 }
3933 */
3934
3935
2/2
✓ Branch 0 taken 18133634 times.
✓ Branch 1 taken 186509 times.
18320143 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3936
3937
2/2
✓ Branch 0 taken 18138907 times.
✓ Branch 1 taken 181236 times.
18320143 if(nosubscr)
3938 {
3939 181236 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3940 181236 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3941 181236 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3942 181236 }
3943
3944 //TODO: Optimize blit 'overcalls' -Gleeok
3945
2/2
✓ Branch 0 taken 181236 times.
✓ Branch 1 taken 18138907 times.
18320143 BITMAP *source = nosubscr ? panorama : wavybuf;
3946 18320143 blit(source,framebuf,0,0,0,0,256,224);
3947
3948 18320143 update_hw_screen();
3949 18320143 }
3950
3951 //----------------------------------------------------------------
3952
3953 static PALETTE syspal;
3954 int32_t onGUISnapshot()
3955 {
3956 char buf[200];
3957 int32_t num=0;
3958 do
3959 {
3960 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3961 }
3962 while(num<99999 && exists(buf));
3963
3964 if (!al_save_bitmap(buf, al_get_backbuffer(all_get_display())))
3965 InfoDialog("Error", "Failed to save snapshot").show();
3966
3967 return D_O_K;
3968 }
3969
3970 int32_t onNonGUISnapshot()
3971 {
3972 PALETTE temppal;
3973 get_palette(temppal);
3974 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3975
3976 char buf[200];
3977 int32_t num=0;
3978
3979 do
3980 {
3981 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3982 }
3983 while(num<99999 && exists(buf));
3984
3985 if ((tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET)) && !(key[KEY_ALT]))
3986 {
3987 BITMAP *b = create_bitmap_ex(8,256,168);
3988 clear_to_color(b,0);
3989 blit(framebuf,b,0,passive_subscreen_height/2,0,0,256,168);
3990 alleg4_save_bitmap(b, SnapshotScale, buf, realpal ? temppal : RAMpal);
3991 destroy_bitmap(b);
3992 }
3993 else
3994 {
3995 alleg4_save_bitmap(framebuf, SnapshotScale, buf, realpal?temppal:RAMpal);
3996 }
3997
3998 return D_O_K;
3999 }
4000
4001 int32_t onSnapshot()
4002 {
4003 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
4004 {
4005 onGUISnapshot();
4006 }
4007 else
4008 {
4009 onNonGUISnapshot();
4010 }
4011
4012 return D_O_K;
4013 }
4014
4015 int32_t onSaveMapPic()
4016 {
4017 int32_t mapres2 = 0;
4018 char buf[200];
4019 int32_t num=0;
4020 mapscr tmpscr_b[2];
4021 mapscr tmpscr_c[6];
4022 BITMAP* _screen_draw_buffer = NULL;
4023 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4024 set_clip_state(_screen_draw_buffer,1);
4025
4026 for(int32_t i=0; i<6; ++i)
4027 {
4028 tmpscr_c[i] = tmpscr2[i];
4029 tmpscr2[i].zero_memory();
4030
4031 if(i>=2)
4032 {
4033 continue;
4034 }
4035
4036 tmpscr_b[i] = tmpscr[i];
4037 tmpscr[i].zero_memory();
4038 }
4039
4040 do
4041 {
4042 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4043 }
4044 while(num<99999 && exists(buf));
4045
4046 BITMAP* mappic = NULL;
4047
4048
4049 bool done=false, redraw=true;
4050
4051 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4052
4053 if(!mappic)
4054 {
4055 enter_sys_pal();
4056 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4057 exit_sys_pal();
4058 return D_O_K;;
4059 }
4060
4061 // draw the map
4062 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4063
4064 for(int32_t y=0; y<8; y++)
4065 {
4066 for(int32_t x=0; x<16; x++)
4067 {
4068 if(!displayOnMap(x, y))
4069 {
4070 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4071 }
4072 else
4073 {
4074 int32_t s = (y<<4) + x;
4075 loadscr2(1,s,-1);
4076
4077 for(int32_t i=0; i<6; i++)
4078 {
4079 if(tmpscr[1].layermap[i]<=0)
4080 continue;
4081
4082 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4083 }
4084
4085 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4086
4087 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4088
4089 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4090 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4091
4092 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4093
4094 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4095 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4096 {
4097 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4098 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4099 {
4100 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4101 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4102 }
4103 }
4104 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4105
4106 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4107
4108 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4109 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4110 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4111 {
4112 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4113 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4114 }
4115 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4116 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4117
4118 }
4119
4120 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4121 }
4122 }
4123
4124 for(int32_t i=0; i<6; ++i)
4125 {
4126 tmpscr2[i]=tmpscr_c[i];
4127
4128 if(i>=2)
4129 {
4130 continue;
4131 }
4132
4133 tmpscr[i]=tmpscr_b[i];
4134 }
4135
4136 save_bitmap(buf,mappic,RAMpal);
4137 destroy_bitmap(mappic);
4138 destroy_bitmap(_screen_draw_buffer);
4139 return D_O_K;
4140 }
4141
4142 61 void f_Quit(int32_t type)
4143 {
4144
2/4
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
61 if(type==qQUIT && !Playing)
4145 return;
4146
4147 61 bool from_menu = is_sys_pal;
4148
4149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(!from_menu)
4150 {
4151 61 music_pause();
4152 61 pause_all_sfx();
4153 61 sys_mouse();
4154 61 }
4155 61 enter_sys_pal();
4156 61 clear_keybuf();
4157
4158
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 13 times.
61 if (replay_version_check(0, 10))
4159 13 replay_poll();
4160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if (replay_is_replaying())
4161 61 replay_peek_quit();
4162
4163
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if (!replay_is_replaying())
4164 switch(type)
4165 {
4166 case qQUIT:
4167 onQuit();
4168 break;
4169
4170 case qRESET:
4171 onReset();
4172 break;
4173
4174 case qEXIT:
4175 onExit();
4176 break;
4177 }
4178
4179
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(Quit)
4180 {
4181 61 kill_sfx();
4182 61 music_stop();
4183 61 exit_sys_pal();
4184 61 update_hw_screen();
4185 61 }
4186 else
4187 {
4188 exit_sys_pal();
4189 if(!from_menu)
4190 {
4191 music_resume();
4192 resume_all_sfx();
4193 }
4194 }
4195
4196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(!from_menu)
4197 61 game_mouse();
4198 61 eat_buttons();
4199
4200 61 zc_readrawkey(KEY_ESC);
4201
4202 61 zc_readrawkey(KEY_ENTER);
4203 61 }
4204
4205 //----------------------------------------------------------------
4206
4207 int32_t onNoWalls()
4208 {
4209 cheats_enqueue(Cheat::Walls);
4210 return D_O_K;
4211 }
4212
4213 int32_t onIgnoreSideview()
4214 {
4215 cheats_enqueue(Cheat::IgnoreSideView);
4216 return D_O_K;
4217 }
4218
4219 18318803 int32_t input_idle(bool checkmouse)
4220 {
4221 static int32_t mx, my, mz, mb;
4222
4223
4/6
✓ Branch 0 taken 18318803 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4908847 times.
✓ Branch 3 taken 13409956 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4908847 times.
23227650 if(keypressed() || zc_key_pressed() ||
4224
4/8
✓ Branch 0 taken 4908847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4908847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4908847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4908847 times.
✗ Branch 7 not taken.
4908847 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4225 {
4226 13409956 idle_count = 0;
4227
4228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13409956 times.
13409956 if(active_count < MAX_ACTIVE)
4229 {
4230 13409956 ++active_count;
4231 13409956 }
4232 13409956 }
4233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4908847 times.
4908847 else if(idle_count < MAX_IDLE)
4234 {
4235 4908847 ++idle_count;
4236 4908847 active_count = 0;
4237 4908847 }
4238
4239 18318803 mx = mouse_x;
4240 18318803 my = mouse_y;
4241 18318803 mz = mouse_z;
4242 18318803 mb = mouse_b;
4243
4244 18318803 return idle_count;
4245 }
4246
4247 int32_t onGoFast()
4248 {
4249 cheats_enqueue(Cheat::Fast);
4250 return D_O_K;
4251 }
4252
4253 int32_t onKillCheat()
4254 {
4255 cheats_enqueue(Cheat::Kill);
4256 return D_O_K;
4257 }
4258
4259 int32_t onSecretsCheat()
4260 {
4261 cheats_enqueue(Cheat::TrigSecrets);
4262 return D_O_K;
4263 }
4264 int32_t onSecretsCheatPerm()
4265 {
4266 cheats_enqueue(Cheat::TrigSecretsPerm);
4267 return D_O_K;
4268 }
4269
4270 int32_t onShowLayer0()
4271 {
4272 show_layer_0 = !show_layer_0;
4273 return D_O_K;
4274 }
4275 int32_t onShowLayer1()
4276 {
4277 show_layer_1 = !show_layer_1;
4278 return D_O_K;
4279 }
4280 int32_t onShowLayer2()
4281 {
4282 show_layer_2 = !show_layer_2;
4283 return D_O_K;
4284 }
4285 int32_t onShowLayer3()
4286 {
4287 show_layer_3 = !show_layer_3;
4288 return D_O_K;
4289 }
4290 int32_t onShowLayer4()
4291 {
4292 show_layer_4 = !show_layer_4;
4293 return D_O_K;
4294 }
4295 int32_t onShowLayer5()
4296 {
4297 show_layer_5 = !show_layer_5;
4298 return D_O_K;
4299 }
4300 int32_t onShowLayer6()
4301 {
4302 show_layer_6 = !show_layer_6;
4303 return D_O_K;
4304 }
4305 int32_t onShowLayerO()
4306 {
4307 show_layer_over=!show_layer_over;
4308 return D_O_K;
4309 }
4310 int32_t onShowLayerP()
4311 {
4312 show_layer_push=!show_layer_push;
4313 return D_O_K;
4314 }
4315 int32_t onShowLayerS()
4316 {
4317 show_sprites=!show_sprites;
4318 return D_O_K;
4319 }
4320 int32_t onShowLayerF()
4321 {
4322 show_ffcs=!show_ffcs;
4323 return D_O_K;
4324 }
4325 int32_t onShowLayerW()
4326 {
4327 show_walkflags=!show_walkflags;
4328 if(show_walkflags)
4329 show_effectflags = false;
4330 return D_O_K;
4331 }
4332 int32_t onShowLayerE()
4333 {
4334 show_effectflags=!show_effectflags;
4335 if(show_effectflags)
4336 show_walkflags = false;
4337 return D_O_K;
4338 }
4339 int32_t onShowFFScripts()
4340 {
4341 show_ff_scripts=!show_ff_scripts;
4342 return D_O_K;
4343 }
4344 int32_t onShowHitboxes()
4345 {
4346 show_hitboxes=!show_hitboxes;
4347 return D_O_K;
4348 }
4349 int32_t onShowInfoOpacity()
4350 {
4351 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4352 zc_set_config("zc","debug_info_opacity",info_opacity);
4353 return D_O_K;
4354 }
4355
4356 int32_t onLightSwitch()
4357 {
4358 cheats_enqueue(Cheat::Light);
4359 return D_O_K;
4360 }
4361
4362 int32_t onGoTo();
4363 int32_t onGoToComplete();
4364
4365 18318803 bool handle_close_btn_quit()
4366 {
4367
1/2
✓ Branch 0 taken 18318803 times.
✗ Branch 1 not taken.
18318803 if(close_button_quit)
4368 {
4369 close_button_quit=false;
4370 f_Quit(qEXIT);
4371 }
4372 18318803 return (exiting_program = Quit==qEXIT);
4373 }
4374
4375 18318803 void syskeys()
4376 {
4377 18318803 update_system_keys();
4378
4379 int32_t oldtitle_version;
4380
4381 18318803 poll_joystick();
4382
4383 18318803 handle_close_btn_quit();
4384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318803 times.
18318803 if(Quit == qEXIT) return;
4385
4386
2/10
✓ Branch 0 taken 18318803 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18318803 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
18318803 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4387 {
4388 System();
4389 }
4390
4391 18318803 mouse_down=gui_mouse_b();
4392
4393
1/2
✓ Branch 0 taken 18318803 times.
✗ Branch 1 not taken.
18318803 if(zc_read_system_key(KEY_F1))
4394 {
4395 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4396 {
4397 halt=!halt;
4398 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4399 }
4400 else
4401 {
4402 Throttlefps=!Throttlefps;
4403 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4404 }
4405 }
4406
4407
1/2
✓ Branch 0 taken 18318803 times.
✗ Branch 1 not taken.
18318803 if(zc_read_system_key(KEY_F2))
4408 {
4409 ShowFPS=!ShowFPS;
4410 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4411 }
4412
4413
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18318803 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18318803 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4414
4415
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18318803 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18318803 if(zc_read_system_key(KEY_F4) && Playing)
4416 {
4417 Paused=true;
4418 Advance=true;
4419 }
4420
4421
1/2
✓ Branch 0 taken 18318803 times.
✗ Branch 1 not taken.
18318803 if(zc_read_system_key(KEY_F6)) onTryQuit();
4422
4423 #ifndef ALLEGRO_MACOSX
4424
1/2
✓ Branch 0 taken 18318803 times.
✗ Branch 1 not taken.
18318803 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4425
4426
1/2
✓ Branch 0 taken 18318803 times.
✗ Branch 1 not taken.
18318803 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4427 #else
4428 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4429
4430 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4431 #endif
4432
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 18318803 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
18318803 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4433
4434
1/2
✓ Branch 0 taken 18318803 times.
✗ Branch 1 not taken.
18318803 if (zc_read_system_key(KEY_F12))
4435 {
4436 onSnapshot();
4437 }
4438
4439
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18318803 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18318803 if(debug_enabled && zc_read_system_key(KEY_TAB))
4440 set_debug(!get_debug());
4441
4442
1/2
✓ Branch 0 taken 18318803 times.
✗ Branch 1 not taken.
18318803 if(CheatModifierKeys())
4443 {
4444 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4445 {
4446 if(!bindable_cheat(c))
4447 continue;
4448 if(get_debug() || cheat >= cheat_lvl(c))
4449 {
4450 if(checkcheat(c))
4451 cheats_hit_bind(c);
4452 }
4453 }
4454 }
4455
4456
1/2
✓ Branch 0 taken 18318803 times.
✗ Branch 1 not taken.
18318803 if(volkeys)
4457 {
4458 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4459
4460 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4461
4462 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4463
4464 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4465 }
4466
4467
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18318803 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18318803 if(!get_debug() || !SystemKeys || replay_is_replaying())
4468 18318803 goto bottom;
4469
4470 if(zc_readkey(KEY_P)) Paused=!Paused;
4471
4472 //if(zc_readkey(KEY_P)) centerHero();
4473 if(zc_readkey(KEY_A))
4474 {
4475 Paused=true;
4476 Advance=true;
4477 }
4478
4479 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4480 #ifndef ALLEGRO_MACOSX
4481 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4482
4483 if(zc_readkey(KEY_F7))
4484 {
4485 Matrix(ss_speed, ss_density, 0);
4486 game_pal();
4487 }
4488 #else
4489 // The reason these are different on Mac in the first place is that
4490 // the OS doesn't let us use F9 and F10...
4491 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4492
4493 if(zc_readkey(KEY_F9))
4494 {
4495 Matrix(ss_speed, ss_density, 0);
4496 game_pal();
4497 }
4498 #endif
4499 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4500 {
4501 //change containers
4502 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4503 {
4504 //magic containers
4505 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4506 {
4507 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4508 }
4509 else
4510 {
4511 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4512 }
4513 }
4514 else
4515 {
4516 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4517 {
4518 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4519 }
4520 else
4521 {
4522 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4523 }
4524 }
4525 }
4526
4527 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4528 {
4529 //change containers
4530 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4531 {
4532 //magic containers
4533 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4534 {
4535 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4536 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4537 //heart containers
4538 }
4539 else
4540 {
4541 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4542 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4543 }
4544 }
4545 else
4546 {
4547 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4548 {
4549 game->set_magic(zc_max(game->get_magic()-1,0));
4550 }
4551 else
4552 {
4553 game->set_life(zc_max(game->get_life()-1,0));
4554 }
4555 }
4556 }
4557
4558 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4559
4560 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4561
4562 verifyBothWeapons();
4563
4564 bottom:
4565
4566
1/2
✓ Branch 0 taken 18318803 times.
✗ Branch 1 not taken.
18318803 if(input_idle(true) > after_time())
4567 {
4568 Matrix(ss_speed, ss_density, 0);
4569 game_pal();
4570 }
4571 18318803 }
4572
4573 1128372 void checkQuitKeys()
4574 {
4575 #ifndef ALLEGRO_MACOSX
4576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1128372 times.
1128372 if(key[KEY_F9]) f_Quit(qRESET);
4577
4578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1128372 times.
1128372 if(key[KEY_F10]) f_Quit(qEXIT);
4579 #else
4580 if(key[KEY_F7]) f_Quit(qRESET);
4581
4582 if(key[KEY_F8]) f_Quit(qEXIT);
4583 #endif
4584 1128372 }
4585
4586 18319003 bool CheatModifierKeys()
4587 {
4588 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4589 // to trigger cheats.
4590
2/2
✓ Branch 0 taken 18318703 times.
✓ Branch 1 taken 300 times.
18319003 if (replay_is_replaying())
4591 18318703 return false;
4592
4593
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
300 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4594
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 100 times.
200 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4596 {
4597
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
200 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4598 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4599 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4600 {
4601 return true;
4602 }
4603 }
4604 100 return false;
4605 18318803 }
4606
4607 //99:05:54, for some reason?
4608 #define OLDMAXTIME 21405240
4609 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4610 #define MAXTIME 1944000000
4611
4612 18320143 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4613 {
4614
1/2
✓ Branch 0 taken 18320143 times.
✗ Branch 1 not taken.
18320143 if(zcmusic!=NULL)
4615 {
4616 zcmusic_poll();
4617 }
4618 18320143 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4619
4620 18320143 updatescr(allowwavy);
4621
4622 18320143 Advance=false;
4623
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18320143 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18320143 times.
18320143 while(Paused && !Advance && !Quit)
4624 {
4625 // have to call this, otherwise we'll get an infinite loop
4626 syskeys();
4627 if(allowF6Script)
4628 {
4629 FFCore.runF6Engine();
4630 }
4631 zc_throttle_fps();
4632
4633 #ifdef _WIN32
4634
4635 if(use_dwm_flush)
4636 {
4637 do_DwmFlush();
4638 }
4639
4640 #endif
4641
4642 // to keep music playing
4643 if(zcmusic!=NULL)
4644 {
4645 zcmusic_poll();
4646 }
4647
4648 update_hw_screen();
4649 }
4650
4651
2/2
✓ Branch 0 taken 18318845 times.
✓ Branch 1 taken 1298 times.
18320143 if(Quit)
4652 1298 return;
4653
4654
3/4
✓ Branch 0 taken 17805837 times.
✓ Branch 1 taken 513008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17805837 times.
18318845 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4655 17805837 game->change_time(1);
4656
4657 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4658
4659 18318845 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4660
2/2
✓ Branch 0 taken 8608546 times.
✓ Branch 1 taken 9710299 times.
18318845 if (replay_version_check(0, 16))
4661 9710299 should_reset_down_state = replay_version_check(11, 16);
4662
2/2
✓ Branch 0 taken 14967988 times.
✓ Branch 1 taken 3350857 times.
18318845 if (should_reset_down_state)
4663 {
4664
2/2
✓ Branch 0 taken 60315426 times.
✓ Branch 1 taken 3350857 times.
63666283 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4665 60315426 down_control_states[i] = raw_control_state[i];
4666 3350857 }
4667
4668
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 18318803 times.
18318845 if (replay_is_active())
4669 {
4670
2/2
✓ Branch 0 taken 1545415 times.
✓ Branch 1 taken 16773388 times.
18318803 if (replay_version_check(3))
4671 16773388 replay_poll();
4672
4673
4/4
✓ Branch 0 taken 7389596 times.
✓ Branch 1 taken 10929207 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 7289061 times.
18318803 if (replay_version_check(11) || replay_version_check(6, 8))
4674 11029742 replay_peek_input();
4675 18318803 }
4676
4677 18318845 load_control_called_this_frame = false;
4678
4679 18318845 poll_keyboard();
4680 18318845 update_keys();
4681
4682 18318845 ++frame;
4683
4684
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 18318703 times.
18318845 if (replay_is_replaying())
4685 18318703 replay_do_cheats();
4686 18318845 syskeys();
4687
4688 // The mouse variables can change from the mouse thread at anytime during a frame,
4689 // so save the result at the start so that replaying is consistent.
4690 18318845 script_mouse_x = gui_mouse_x();
4691 18318845 script_mouse_y = gui_mouse_y();
4692 18318845 script_mouse_z = mouse_z;
4693 18318845 script_mouse_b = mouse_b;
4694
4695 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4696 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4697 // approach here means it doesn't matter which call adds the cheat.
4698 18318845 cheats_execute_queued();
4699
4700
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 18318703 times.
18318845 if (replay_is_replaying())
4701 18318703 replay_peek_quit();
4702
2/2
✓ Branch 0 taken 18318784 times.
✓ Branch 1 taken 61 times.
18318845 if (GameFlags & GAMEFLAG_TRYQUIT)
4703 61 replay_step_quit(0);
4704
2/2
✓ Branch 0 taken 3692 times.
✓ Branch 1 taken 18315153 times.
18318845 if(allowF6Script)
4705 18315153 FFCore.runF6Engine();
4706
2/2
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 18318106 times.
18318845 if (Quit)
4707 739 replay_step_quit(Quit);
4708 // Someday... maybe install a Turbo button here?
4709 18318845 zc_throttle_fps();
4710
4711 #ifdef _WIN32
4712
4713 if(use_dwm_flush)
4714 {
4715 do_DwmFlush();
4716 }
4717
4718 #endif
4719
4720 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4721
2/2
✓ Branch 0 taken 208650 times.
✓ Branch 1 taken 18110195 times.
18318845 if(sfxcleanup)
4722 18110195 sfx_cleanup();
4723
4724 18318845 jit_poll();
4725
4726 #ifdef __EMSCRIPTEN__
4727 // Yield the main thread back to the browser occasionally.
4728 if (is_headless())
4729 {
4730 static int rate = 10000;
4731 static int force_yield = rate;
4732 if (force_yield++ >= rate)
4733 {
4734 force_yield = 0;
4735 emscripten_sleep(0);
4736 }
4737 }
4738 #endif
4739
4740
4/6
✓ Branch 0 taken 257 times.
✓ Branch 1 taken 18318588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 257 times.
✓ Branch 4 taken 257 times.
✗ Branch 5 not taken.
18318845 static bool test_mode_auto_restart = zc_get_config("zeldadx", "test_mode_auto_restart", false);
4741
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 18318745 times.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
18318845 if (zqtesting_mode && test_mode_auto_restart)
4742 {
4743 static auto last_write_time = fs::last_write_time(qstpath);
4744 static auto last_check = std::chrono::system_clock::now();
4745
4746 if (std::chrono::system_clock::now() - last_check > 200ms)
4747 {
4748 last_check = std::chrono::system_clock::now();
4749 auto write_time = fs::last_write_time(qstpath);
4750 if (last_write_time != write_time)
4751 {
4752 last_write_time = write_time;
4753 disableClickToFreeze = false;
4754 Quit = qRESET;
4755 replay_quit();
4756 }
4757 }
4758 }
4759 18320143 }
4760
4761 589 void zapout()
4762 {
4763 589 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4764 589 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4765
4766 589 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4767 589 script_drawing_commands.Clear();
4768
4769 // zap out
4770
2/2
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 14136 times.
14725 for(int32_t i=1; i<=24; i++)
4771 {
4772 14136 draw_fuzzy(i);
4773 14136 advanceframe(true);
4774
4775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14136 times.
14136 if(Quit)
4776 {
4777 break;
4778 }
4779 14136 }
4780 589 }
4781
4782 587 void zapin()
4783 {
4784 587 FFCore.warpScriptCheck();
4785 587 draw_screen(tmpscr);
4786 587 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4787 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4788 587 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4789
4790 // zap out
4791 587 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4792
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 14088 times.
14675 for(int32_t i=24; i>=1; i--)
4793 {
4794 14088 draw_fuzzy(i);
4795 14088 advanceframe(true);
4796
4797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14088 times.
14088 if(Quit)
4798 {
4799 break;
4800 }
4801 14088 }
4802 587 }
4803
4804
4805 235 void wavyout(bool showhero)
4806 {
4807 235 draw_screen(tmpscr, showhero);
4808 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4809
4810 235 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4811 235 clear_to_color(wavebuf,0);
4812 235 blit(framebuf,wavebuf,0,0,16,0,256,224);
4813
4814 static PALETTE wavepal;
4815
4816 int32_t ofs;
4817 235 int32_t amplitude=8;
4818
4819 235 int32_t wavelength=4;
4820 235 double palpos=0, palstep=4, palstop=126;
4821
4822 235 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4823
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 9845 times.
10079 for(int32_t i=0; i<168; i+=wavelength)
4824 {
4825
2/2
✓ Branch 0 taken 2520320 times.
✓ Branch 1 taken 9845 times.
2530165 for(int32_t l=0; l<256; l++)
4826 {
4827 2520320 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4828 2520320 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4829 2520320 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4830 2520320 }
4831
4832 9845 palpos+=palstep;
4833
4834
1/2
✓ Branch 0 taken 9845 times.
✗ Branch 1 not taken.
9845 if(palpos>=0)
4835 {
4836 9845 hw_palette = &wavepal;
4837 9845 update_hw_pal = true;
4838 9845 }
4839 else
4840 {
4841 hw_palette = &RAMpal;
4842 update_hw_pal = true;
4843 }
4844
4845
2/2
✓ Branch 0 taken 1653960 times.
✓ Branch 1 taken 9845 times.
1663805 for(int32_t j=0; j+playing_field_offset<224; j++)
4846 {
4847
2/2
✓ Branch 0 taken 423413760 times.
✓ Branch 1 taken 1653960 times.
425067720 for(int32_t k=0; k<256; k++)
4848 {
4849 423413760 ofs=0;
4850
4851
4/4
✓ Branch 0 taken 206448640 times.
✓ Branch 1 taken 216965120 times.
✓ Branch 2 taken 103224320 times.
✓ Branch 3 taken 103224320 times.
423413760 if((j<i)&&(j&1))
4852 {
4853 103224320 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4854 103224320 }
4855
4856 423413760 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4857 423413760 }
4858 1653960 }
4859
4860 9845 advanceframe(true);
4861
4862 // animate_combos();
4863
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9844 times.
9845 if(Quit)
4864 1 break;
4865 9844 }
4866
4867 235 destroy_bitmap(wavebuf);
4868 235 }
4869
4870 232 void wavyin()
4871 {
4872 232 draw_screen(tmpscr);
4873 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4874
4875 232 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4876 232 clear_to_color(wavebuf,0);
4877 232 blit(framebuf,wavebuf,0,0,16,0,256,224);
4878
4879 static PALETTE wavepal;
4880
4881 //Breaks dark rooms.
4882 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4883 /*
4884 loadfullpal();
4885 loadlvlpal(DMaps[currdmap].color);
4886 ringcolor(false);
4887 */
4888 232 refreshpal=false;
4889 int32_t ofs;
4890 232 int32_t amplitude=8;
4891 232 int32_t wavelength=4;
4892 232 double palpos=168, palstep=4, palstop=126;
4893
4894 232 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4895
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 9703 times.
9934 for(int32_t i=0; i<168; i+=wavelength)
4896 {
4897
2/2
✓ Branch 0 taken 2483968 times.
✓ Branch 1 taken 9703 times.
2493671 for(int32_t l=0; l<256; l++)
4898 {
4899 2483968 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4900 2483968 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4901 2483968 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4902 2483968 }
4903
4904 9703 palpos-=palstep;
4905
4906
1/2
✓ Branch 0 taken 9703 times.
✗ Branch 1 not taken.
9703 if(palpos>=0)
4907 {
4908 9703 hw_palette = &wavepal;
4909 9703 update_hw_pal = true;
4910 9703 }
4911 else
4912 {
4913 hw_palette = &RAMpal;
4914 update_hw_pal = true;
4915 }
4916
4917
2/2
✓ Branch 0 taken 1630104 times.
✓ Branch 1 taken 9703 times.
1639807 for(int32_t j=0; j+playing_field_offset<224; j++)
4918 {
4919
2/2
✓ Branch 0 taken 417306624 times.
✓ Branch 1 taken 1630104 times.
418936728 for(int32_t k=0; k<256; k++)
4920 {
4921 417306624 ofs=0;
4922
4923
4/4
✓ Branch 0 taken 211158272 times.
✓ Branch 1 taken 206148352 times.
✓ Branch 2 taken 106821120 times.
✓ Branch 3 taken 104337152 times.
417306624 if((j<(167-i))&&(j&1))
4924 {
4925 104337152 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4926 104337152 }
4927
4928 417306624 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4929 417306624 }
4930 1630104 }
4931
4932 9703 advanceframe(true);
4933 // animate_combos();
4934
4935
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9702 times.
9703 if(Quit)
4936 1 break;
4937 9702 }
4938
4939 232 destroy_bitmap(wavebuf);
4940 232 }
4941
4942 4326 void blackscr(int32_t fcnt,bool showsubscr)
4943 {
4944 4326 reset_pal_cycling();
4945 4326 script_drawing_commands.Clear();
4946
4947 4326 FFCore.warpScriptCheck();
4948 4326 bool showtime = game->should_show_time();
4949
2/2
✓ Branch 0 taken 4319 times.
✓ Branch 1 taken 129337 times.
133656 while(fcnt>0)
4950 {
4951 129337 clear_bitmap(framebuf);
4952
4953
2/2
✓ Branch 0 taken 59250 times.
✓ Branch 1 taken 70087 times.
129337 if(showsubscr)
4954 {
4955 70087 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4956
3/4
✓ Branch 0 taken 70087 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1230 times.
✓ Branch 3 taken 68857 times.
70087 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4957 {
4958 1230 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4959 1230 }
4960 70087 }
4961
4962 129337 advanceframe(true);
4963
4964
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 129330 times.
129337 if(Quit)
4965 7 break;
4966
4967 129330 --fcnt;
4968 }
4969 4326 }
4970
4971 2667 void openscreen(int32_t shape)
4972 {
4973 2667 reset_pal_cycling();
4974 2667 black_opening_count=0;
4975
4976
3/4
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 2145 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 522 times.
2667 if(COOLSCROLL || shape>-1)
4977 {
4978 2145 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4979 2145 return;
4980 }
4981 else
4982 {
4983 522 Hero.setDontDraw(true);
4984 522 show_subscreen_dmap_dots=false;
4985 522 show_subscreen_numbers=false;
4986 522 show_subscreen_life=false;
4987 }
4988
4989 522 int32_t x=128;
4990
4991 522 FFCore.warpScriptCheck();
4992
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 41760 times.
42282 for(int32_t i=0; i<80; i++)
4993 {
4994 41760 draw_screen(tmpscr);
4995 //? draw_screen already draws the subscreen -DD
4996 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4997 41760 x=128-(((i*128/80)/8)*8);
4998
4999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41760 times.
41760 if(x>0)
5000 {
5001 41760 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5002 41760 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5003 41760 }
5004
5005 41760 advanceframe(true);
5006
5007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41760 times.
41760 if(Quit)
5008 {
5009 break;
5010 }
5011 41760 }
5012
5013 522 Hero.setDontDraw(false);
5014 522 show_subscreen_items=true;
5015 522 show_subscreen_dmap_dots=true;
5016 522 show_subscreen_numbers=true;
5017 522 show_subscreen_life=true;
5018 2667 }
5019
5020 4 void closescreen(int32_t shape)
5021 {
5022 4 reset_pal_cycling();
5023 4 black_opening_count=0;
5024
5025
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if(COOLSCROLL || shape>-1)
5026 {
5027 4 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5028 4 return;
5029 }
5030 else
5031 {
5032 Hero.setDontDraw(true);
5033 show_subscreen_dmap_dots=false;
5034 show_subscreen_numbers=false;
5035 // show_subscreen_items=false;
5036 show_subscreen_life=false;
5037 }
5038
5039 int32_t x=128;
5040
5041 FFCore.warpScriptCheck();
5042 for(int32_t i=79; i>=0; --i)
5043 {
5044 draw_screen(tmpscr);
5045 //? draw_screen already draws the subscreen -DD
5046 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5047 x=128-(((i*128/80)/8)*8);
5048
5049 if(x>0)
5050 {
5051 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5052 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5053 }
5054
5055 advanceframe(true);
5056
5057 if(Quit)
5058 {
5059 break;
5060 }
5061 }
5062
5063 Hero.setDontDraw(false);
5064 show_subscreen_items=true;
5065 show_subscreen_dmap_dots=true;
5066 4 }
5067
5068 296 int32_t TriforceCount()
5069 {
5070 296 int32_t c=0;
5071
5072
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 296 times.
2664 for(int32_t i=1; i<=8; i++)
5073
2/2
✓ Branch 0 taken 484 times.
✓ Branch 1 taken 1884 times.
4252 if(game->lvlitems[i]&liTRIFORCE)
5074 1884 ++c;
5075
5076 296 return c;
5077 }
5078
5079 int32_t onCustomGame()
5080 {
5081 int32_t file = getsaveslot();
5082
5083 if(file < 0)
5084 return D_O_K;
5085
5086 bool ret = (custom_game(file)!=0);
5087 return ret ? D_CLOSE : D_O_K;
5088 }
5089
5090 int32_t onContinue()
5091 {
5092 return D_CLOSE;
5093 }
5094
5095 int32_t onEsc() // Unused?? -L
5096 {
5097 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5098 }
5099
5100 int32_t onThrottleFPS()
5101 {
5102 Throttlefps = !Throttlefps;
5103 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5104 return D_O_K;
5105 }
5106
5107 int32_t onWinPosSave()
5108 {
5109 SaveWinPos = !SaveWinPos;
5110 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5111 return D_O_K;
5112 }
5113 int32_t onIntegerScaling()
5114 {
5115 scaleForceInteger = !scaleForceInteger;
5116 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5117 return D_O_K;
5118 }
5119 int32_t onStretchGame()
5120 {
5121 stretchGame = !stretchGame;
5122 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5123 return D_O_K;
5124 }
5125
5126 int32_t onClickToFreeze()
5127 {
5128 ClickToFreeze = !ClickToFreeze;
5129 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5130 return D_O_K;
5131 }
5132
5133 int32_t OnSaveZCConfig()
5134 {
5135 if(jwin_alert3(
5136 "Save Configuration",
5137 "Are you sure that you wish to save your present configuration settings?",
5138 "This will overwrite your prior settings!",
5139 NULL,
5140 "&Yes",
5141 "&No",
5142 NULL,
5143 'y',
5144 'n',
5145 0,
5146 get_zc_font(font_lfont)) == 1)
5147 {
5148 save_game_configs();
5149 return D_O_K;
5150 }
5151 else return D_O_K;
5152 }
5153
5154 int32_t OnnClearQuestDir()
5155 {
5156 auto current_path = fs::current_path() / "quests";
5157 if(jwin_alert3(
5158 "Clear Current Directory Cache",
5159 "Are you sure that you wish to reset where ZC Player looks for quests?",
5160 fmt::format("The new directory will be: {}", current_path.string()).c_str(),
5161 NULL,
5162 "&Yes",
5163 "&No",
5164 NULL,
5165 'y',
5166 'n',
5167 0,
5168 get_zc_font(font_lfont)) == 1)
5169 {
5170 zc_set_config("zeldadx","quest_dir","quests");
5171 flush_config_file();
5172 strcpy(qstdir,"quests");
5173 #ifdef __EMSCRIPTEN__
5174 em_sync_fs();
5175 #endif
5176 return D_O_K;
5177 }
5178 else return D_O_K;
5179 }
5180
5181 int32_t onConsole()
5182 {
5183 if ( !console_enabled )
5184 {
5185 AlertDialog("ZC Console",
5186 "Open the ZC Console?"
5187 "\nThis will display any messages logged by scripts,"
5188 " including errors.",
5189 [&](bool ret,bool)
5190 {
5191 if(ret)
5192 {
5193 FFCore.ZScriptConsole(true);
5194 }
5195 }).show();
5196 return D_O_K;
5197 }
5198 else
5199 {
5200 FFCore.ZScriptConsole(false);
5201 return D_O_K;
5202 }
5203 }
5204
5205 int32_t onClrConsoleOnReload()
5206 {
5207 clearConsoleOnReload = !clearConsoleOnReload;
5208 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5209 return D_O_K;
5210 }
5211 int32_t onClrConsoleOnLoad()
5212 {
5213 clearConsoleOnLoad = !clearConsoleOnLoad;
5214 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5215 return D_O_K;
5216 }
5217
5218
5219 int32_t onFrameSkip()
5220 {
5221 FrameSkip = !FrameSkip;
5222 return D_O_K;
5223 }
5224
5225 int32_t onSaveDragResize()
5226 {
5227 SaveDragResize = !SaveDragResize;
5228 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5229 return D_O_K;
5230 }
5231
5232 int32_t onDragAspect()
5233 {
5234 DragAspect = !DragAspect;
5235 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5236 return D_O_K;
5237 }
5238
5239 int32_t onTransLayers()
5240 {
5241 TransLayers = !TransLayers;
5242 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5243 return D_O_K;
5244 }
5245
5246 int32_t onNESquit()
5247 {
5248 NESquit = !NESquit;
5249 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5250 return D_O_K;
5251 }
5252
5253 int32_t onVolKeys()
5254 {
5255 volkeys = !volkeys;
5256 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5257 return D_O_K;
5258 }
5259
5260 int32_t onShowFPS()
5261 {
5262 ShowFPS = !ShowFPS;
5263 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5264 return D_O_K;
5265 }
5266
5267 int32_t onShowTime()
5268 {
5269 ShowGameTime = !ShowGameTime;
5270 zc_set_config(cfg_sect,"showtime",ShowGameTime);
5271 return D_O_K;
5272 }
5273
5274 2161618754 bool is_Fkey(int32_t k)
5275 {
5276
2/2
✓ Branch 0 taken 219825636 times.
✓ Branch 1 taken 1941793118 times.
2161618754 switch(k)
5277 {
5278 case KEY_F1:
5279 case KEY_F2:
5280 case KEY_F3:
5281 case KEY_F4:
5282 case KEY_F5:
5283 case KEY_F6:
5284 case KEY_F7:
5285 case KEY_F8:
5286 case KEY_F9:
5287 case KEY_F10:
5288 case KEY_F11:
5289 case KEY_F12:
5290 219825636 return true;
5291 }
5292
5293 1941793118 return false;
5294 2161618754 }
5295
5296 void kb_getkey(DIALOG *d);
5297
5298 //Used by all keyboard key settings dialogues.
5299 void kb_clearjoystick(DIALOG *d)
5300 {
5301 d->flags|=D_SELECTED;
5302
5303 jwin_button_proc(MSG_DRAW,d,0);
5304 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5305 // text_mode(vc(11));
5306 textout_centre_ex(screen, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5307 textout_centre_ex(screen, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5308
5309 update_hw_screen(true);
5310
5311 clear_keybuf();
5312 int32_t k = next_press_key();
5313 clear_keybuf();
5314
5315 //shnarf
5316 //47=f1
5317 //59=esc
5318 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5319 // *((int32_t*)d->dp3) = k;
5320 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5321
5322
5323 d->flags&=~D_SELECTED;
5324 }
5325
5326 //Clears key to 0.
5327 //Used by all keyboard key settings dialogues.
5328 void kb_clearkey(DIALOG *d);
5329
5330 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5331 {
5332 switch(msg)
5333 {
5334 case MSG_KEY:
5335 case MSG_CLICK:
5336
5337 kb_clearjoystick(d);
5338
5339 while(gui_mouse_b())
5340 {
5341 clear_keybuf();
5342 rest(1);
5343 }
5344
5345 return D_REDRAW;
5346 }
5347
5348 return jwin_button_proc(msg,d,c);
5349 }
5350
5351 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5352 //Only used in keyboard settings dialogues to clear keys.
5353 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5354
5355 int32_t j_getbtn(DIALOG *d)
5356 {
5357 d->flags|=D_SELECTED;
5358 jwin_button_proc(MSG_DRAW,d,0);
5359 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5360 // text_mode(vc(11));
5361 int32_t y = screen->h/2 - 12;
5362 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5363 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5364 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5365
5366 update_hw_screen(true);
5367
5368 int32_t b = next_joy_input(true);
5369 if (b == -2)
5370 return D_CLOSE;
5371
5372 if(b>=0)
5373 *((int32_t*)d->dp3) = b;
5374
5375 d->flags&=~D_SELECTED;
5376
5377 return D_O_K;
5378 }
5379
5380 void j_getstick(DIALOG *d)
5381 {
5382 d->flags|=D_SELECTED;
5383 jwin_button_proc(MSG_DRAW,d,0);
5384 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5385 // text_mode(vc(11));
5386 int32_t y = screen->h/2 - 12;
5387 textout_centre_ex(screen, font, "Move a stick (or DPAD)", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5388 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5389 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5390
5391 update_hw_screen(true);
5392
5393 int32_t b = next_joy_input(false);
5394
5395 if(b>=0)
5396 *((int32_t*)d->dp3) = b;
5397
5398 d->flags&=~D_SELECTED;
5399 }
5400
5401 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5402 {
5403 switch(msg)
5404 {
5405 case MSG_KEY:
5406 case MSG_CLICK:
5407
5408 int ret = j_getbtn(d);
5409 if (ret != D_O_K)
5410 return ret;
5411
5412 while(gui_mouse_b()) {
5413 rest(1);
5414 clear_keybuf();
5415 }
5416
5417 return D_REDRAW;
5418 }
5419
5420 return jwin_button_proc(msg,d,c);
5421 }
5422
5423 int32_t d_jstick_proc(int32_t msg,DIALOG *d,int32_t c)
5424 {
5425 switch(msg)
5426 {
5427 case MSG_KEY:
5428 case MSG_CLICK:
5429
5430 j_getstick(d);
5431
5432 while(gui_mouse_b()) {
5433 rest(1);
5434 clear_keybuf();
5435 }
5436
5437 return D_REDRAW;
5438 }
5439
5440 return jwin_button_proc(msg,d,c);
5441 }
5442
5443 //shnarf
5444 extern const char *key_str[];
5445 std::string get_keystr(int key);
5446
5447 const char *pan_str[4] = { " MONO", " 1/2", " 3/4", " FULL" };
5448
5449 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5450 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80],
5451 str_primary_stick[80], str_secondary_stick[80];
5452
5453 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5454 {
5455 //these are here to bypass compiler warnings about unused arguments
5456 c=c;
5457
5458 if (d->w == 1)
5459 {
5460 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
5461 {
5462 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
5463 return D_CLOSE;
5464 }
5465 }
5466
5467 if(msg==MSG_DRAW)
5468 {
5469 switch(d->w)
5470 {
5471 case 0:
5472 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5473 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5474 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5475 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5476 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5477 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5478 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5479 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5480 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5481 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5482 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5483 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5484 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5485 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5486 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5487 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5488 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5489 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5490 break;
5491
5492 case 1:
5493 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5494 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5495 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5496 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5497 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5498 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5499 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5500 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5501 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5502 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5503 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5504 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5505 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5506 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5507 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5508 sprintf(str_primary_stick,"%03d\n%s",js_stick_1_x_stick,joystick_name(js_stick_1_x_stick));
5509 sprintf(str_secondary_stick,"%03d\n%s",js_stick_2_x_stick,joystick_name(js_stick_2_x_stick));
5510 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5511 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5512 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5513 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5514 break;
5515
5516 case 2:
5517 sprintf(str_a," %3d",midi_volume);
5518 sprintf(str_l," %3d",emusic_volume);
5519 sprintf(str_r," %3d",sfx_volume);
5520 strcpy(str_s,pan_str[pan_style]);
5521 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5522 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5523 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5524 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5525 break;
5526 }
5527 }
5528
5529 return D_O_K;
5530 }
5531
5532 int32_t set_vol(void *dp3, int32_t d2)
5533 {
5534 switch(((int32_t*)dp3)[0])
5535 {
5536 case 0:
5537 midi_volume = zc_min(d2<<3,255);
5538 break;
5539
5540 case 1:
5541 digi_volume = zc_min(d2<<3,255);
5542 break;
5543
5544 case 2:
5545 emusic_volume = zc_min(d2<<3,255);
5546 break;
5547
5548 case 3:
5549 sfx_volume = zc_min(d2<<3,255);
5550 break;
5551 }
5552
5553 // text_mode(vc(11));
5554 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]," %3d",zc_min(d2<<3,255));
5555 return D_O_K;
5556 }
5557
5558 int32_t set_pan(void *dp3, int32_t d2)
5559 {
5560 pan_style = vbound(d2,0,3);
5561 // text_mode(vc(11));
5562 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5563 return D_O_K;
5564 }
5565
5566 static int32_t gamepad_joys_list[] =
5567 {
5568 61,
5569 -1
5570 };
5571
5572 static int32_t gamepad_btn_list[] =
5573 {
5574 6,
5575 7,8,9,10,11,12,13,14,15,16,17,
5576 18,19,20,21,22,23,24,25,26,27,28,
5577 29,30,31,32,33,34,35,36,37,38,39,
5578 -1
5579 };
5580
5581 static int32_t gamepad_dirs_list[] =
5582 {
5583 40,41,42,43,
5584 44,45,46,47,
5585 48,49,50,51,
5586 52,53,54,55,
5587 56,57,58,59,
5588 60,
5589 -1
5590 };
5591
5592 static TABPANEL gamepad_tabs[] =
5593 {
5594 // (text)
5595 { (char *)"Controllers", D_SELECTED, gamepad_joys_list, 0, NULL },
5596 { (char *)"Buttons", 0, gamepad_btn_list, 0, NULL },
5597 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5598 { NULL, 0, NULL, 0, NULL }
5599 };
5600
5601 const char *joy_list(int32_t index, int32_t *list_size)
5602 {
5603 if (index == -1)
5604 {
5605 *list_size = al_get_num_joysticks();
5606 return NULL;
5607 }
5608
5609 ALLEGRO_JOYSTICK* joy = al_get_joystick(index);
5610 if (!joy)
5611 {
5612 return "?";
5613 }
5614
5615 return al_get_joystick_name(joy);
5616 }
5617
5618 351 static ListData joy__list(joy_list, &font);
5619
5620 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c)
5621 {
5622 int32_t d2 = d->d2;
5623 int32_t ret = jwin_droplist_proc(msg,d,c);
5624
5625 if(d2!=d->d2)
5626 {
5627 joystick_index = d->d2;
5628 ret |= D_REDRAW_ALL;
5629 }
5630
5631 return ret;
5632 }
5633
5634 static DIALOG gamepad_dlg[] =
5635 {
5636 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5637 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5638 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5639 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5640 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5641 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5642 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5643 // 6
5644 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5645 // 7
5646 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5647 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5648 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5649 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5650 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5651 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5652 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5653 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5654 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5655 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5656 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5657 // 18
5658 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5659 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5660 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5661 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5662 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5663 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5664 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5665 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5666 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5667 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5668 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5669 // 29
5670 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5671 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5672 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5673 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5674 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5675 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5676 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5677 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5678 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5679 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5680 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5681 // 40
5682 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5683 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5684 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5685 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5686 // 44
5687 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5688 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5689 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5690 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5691 // 48
5692 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5693 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5694 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5695 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5696 // 52
5697 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5698 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5699 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5700 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5701 // 56
5702 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Primary: Use Analog Stick (Ignore above and use below instead)", NULL, NULL },
5703 { d_jstick_proc, 22, 165, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Primary", NULL, &js_stick_1_x_stick },
5704 { d_jstick_proc, 22, 195, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Secondary", NULL, &js_stick_2_x_stick },
5705 { jwin_text_proc, 90, 165, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_primary_stick, NULL, NULL },
5706 { jwin_text_proc, 90, 195, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_secondary_stick, NULL, NULL },
5707
5708 // 61
5709 { d_joylist_proc, 22, 62, 150, 16, 0, 0, 0, 0, 0, 0, (void *) &joy__list, NULL, NULL },
5710
5711 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5712 };
5713
5714 static int32_t keyboard_keys_list[] =
5715 {
5716 6,7,8,9,10,
5717 11,12,13,14,15,16,17,18,19,20,
5718 21,22,23,24,25,26,27,28,29,30,
5719 31,32,33,34,35,36,37,38,39,40,
5720 -1
5721 };
5722
5723 static int32_t keyboard_dirs_list[] =
5724 {
5725 41,42,43,44,
5726 45,46,47,48,
5727 49,50,51,52,
5728 53,54,55,56,
5729 -1
5730 };
5731
5732 static int32_t keyboard_mods_list[] =
5733 {
5734 57,58,59,60,
5735 61,62,63,64,
5736 65,66,67,68,
5737 69,70,71,72,
5738 -1
5739 };
5740
5741 static TABPANEL keyboard_control_tabs[] =
5742 {
5743 // (text)
5744 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5745 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5746 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5747 { NULL, 0, NULL, 0, NULL }
5748 };
5749
5750 static DIALOG keyboard_control_dlg[] =
5751 {
5752 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5753 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5754 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5755 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5756 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5757 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5758 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5759 // Keys
5760 // 6
5761 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5762 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5763 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5764 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5765 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5766 // 11
5767 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5768 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5769 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5770 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5771 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5772 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5773 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5774 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5775 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5776 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5777 // 21
5778 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5779 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5780 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5781 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5782 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5783 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5784 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5785 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5786 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5787 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5788 // 31
5789 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5790 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5791 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5792 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5793 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5794 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5795 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5796 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5797 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5798 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5799 // Dirs
5800 // 41
5801 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5802 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5803 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5804 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5805 // 45
5806 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5807 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5808 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5809 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5810 // 49
5811 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5812 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5813 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5814 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5815 // 53
5816 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5817 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5818 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5819 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5820 // Mods
5821 // 57
5822 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5823 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5824 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5825 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5826 // 61
5827 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5828 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5829 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5830 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5831 // 65
5832 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5833 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5834 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5835 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5836 // 69
5837 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5838 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5839 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5840 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5841 // 73
5842 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5843 };
5844
5845 int32_t midi_dp[3] = {0,0,0};
5846 int32_t emus_dp[3] = {2,0,0};
5847 int32_t sfx_dp[3] = {3,0,0};
5848 int32_t pan_dp[3] = {0,0,0};
5849
5850 static DIALOG sound_dlg[] =
5851 {
5852 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5853 351 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5854 351 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5855 351 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5856 351 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5857 351 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5858 351 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5859 351 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5860 351 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5861 351 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5862 351 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5863 // 10
5864 351 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5865 351 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5866 351 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5867 351 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5868 351 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5869 351 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5870 351 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5871 351 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5872 351 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5873 351 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5874 //20
5875 351 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5876 351 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5877 351 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5878 351 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5879 351 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "MIDI Volume", NULL, NULL },
5880 351 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Music Volume (Enhanced Music)", NULL, NULL },
5881 351 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5882 351 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5883 351 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5884 351 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5885 //30
5886 351 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5887 351 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5888 351 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5889 };
5890
5891 char zc_builddate[80];
5892 char zc_aboutstr[80];
5893
5894 static DIALOG about_dlg[] =
5895 {
5896 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5897 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5898 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5899 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5900 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5901 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5902 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5903 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5904 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5905 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5906 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5907 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5908 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5909 };
5910
5911
5912 static DIALOG quest_dlg[] =
5913 {
5914 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5915 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5916 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5917 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5918 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5919 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5920 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5921 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5922 { jwin_text_proc, 130, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5923 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5924 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5925 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5926 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5927 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5928 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5929 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5930 };
5931
5932 static DIALOG triforce_dlg[] =
5933 {
5934 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5935 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5936 // 1
5937 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5938 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5939 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5940 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5941 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5942 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5943 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5944 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5945 // 9
5946 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5947 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5948 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5949 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5950 };
5951
5952 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5953 {
5954 go();
5955 int32_t ret=0;
5956 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5957 comeback();
5958 return ret != 0;
5959 }
5960
5961
5962 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5963 {
5964 if(def!=modulepath)
5965 strcpy(modulepath,def);
5966
5967 if(!usefilename)
5968 {
5969 int32_t i=(int32_t)strlen(modulepath);
5970
5971 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5972 modulepath[i--]=0;
5973 }
5974
5975 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5976 int32_t ret=0;
5977 int32_t sel=0;
5978
5979 if(list==NULL)
5980 {
5981 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
5982 }
5983 else
5984 {
5985 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
5986 }
5987
5988 return ret!=0;
5989 }
5990
5991 int32_t onToggleRecordingNewSaves()
5992 {
5993 if (zc_get_config("zeldadx", "replay_new_saves", false))
5994 {
5995 zc_set_config("zeldadx", "replay_new_saves", false);
5996 }
5997 else
5998 {
5999 zc_set_config("zeldadx", "replay_new_saves", true);
6000 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6001 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6002 }
6003 return D_O_K;
6004 }
6005
6006 int32_t onToggleSnapshotAllFrames()
6007 {
6008 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6009 return D_O_K;
6010 }
6011
6012 int32_t onStopReplayOrRecord()
6013 {
6014 if (replay_is_replaying())
6015 {
6016 replay_quit();
6017 }
6018 else if (replay_get_mode() == ReplayMode::Record)
6019 {
6020 if (!replay_get_meta_bool("test_mode"))
6021 {
6022 jwin_alert("Recording", "You cannot stop recording a save file.",
6023 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6024 return D_CLOSE;
6025 }
6026
6027 if (jwin_alert("Stop Recording",
6028 "Save replay to disk and stop recording?",
6029 "This will stop the recording.",
6030 NULL,
6031 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6032 return D_CLOSE;
6033
6034 replay_save();
6035 replay_stop();
6036 }
6037 return D_O_K;
6038 }
6039
6040 static int32_t handle_on_load_replay(ReplayMode mode)
6041 {
6042 bool ctrl = CHECK_CTRL_CMD;
6043 if (Playing)
6044 {
6045 if (jwin_alert("Replay - Warning!",
6046 "Loading a replay will exit the current game.",
6047 "All unsaved progress will be lost.",
6048 "Do you wish to continue?",
6049 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6050 return D_CLOSE;
6051 }
6052
6053 std::string mode_string = replay_mode_to_string(mode);
6054 mode_string[0] = std::toupper(mode_string[0]);
6055
6056 std::string line_1 = "Select a replay file to play back.";
6057 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6058 std::string line_3 = "You can stop the replay and take over manually any time.";
6059 if (mode == ReplayMode::Update)
6060 {
6061 line_1 = "Select a replay file to update.";
6062 line_2 = "WARNING: be sure to back up the zplay file";
6063 line_3 = "and verify that the updated replay works as expected!";
6064 }
6065
6066 if (jwin_alert(mode_string.c_str(),
6067 line_1.c_str(),
6068 line_2.c_str(),
6069 line_3.c_str(),
6070 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6071 {
6072 char replay_path[2048];
6073 strcpy(replay_path, "replays/");
6074 if(ctrl && devpwd())
6075 strcpy(replay_path, "../../tests/replays");
6076 if (jwin_file_select_ex(
6077 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6078 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6079 return D_CLOSE;
6080
6081 replay_quit();
6082 load_replay_file_deferred(mode, replay_path);
6083 Quit = qRESET;
6084 return D_CLOSE;
6085 }
6086 return D_O_K;
6087 }
6088
6089 int32_t onLoadReplay()
6090 {
6091 return handle_on_load_replay(ReplayMode::Replay);
6092 }
6093
6094 int32_t onLoadReplayAssert()
6095 {
6096 return handle_on_load_replay(ReplayMode::Assert);
6097 }
6098
6099 int32_t onLoadReplayUpdate()
6100 {
6101 return handle_on_load_replay(ReplayMode::Update);
6102 }
6103
6104 int32_t onSaveReplay()
6105 {
6106 if (replay_get_mode() == ReplayMode::Record)
6107 {
6108 if (!replay_get_meta_bool("test_mode"))
6109 {
6110 if (jwin_alert("Save Replay",
6111 "This will save a copy of the replay up to this point.",
6112 "The official replay file will be untouched.",
6113 "Do you wish to continue?",
6114 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6115 return D_CLOSE;
6116
6117 char replay_path[2048];
6118 strcpy(replay_path, replay_get_replay_path().string().c_str());
6119 if (jwin_file_select_ex(
6120 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6121 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6122 return D_CLOSE;
6123
6124 if (fileexists(replay_path))
6125 {
6126 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6127 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6128 return D_CLOSE;
6129 }
6130
6131 replay_save(replay_path);
6132 }
6133 else
6134 {
6135 replay_save();
6136 }
6137 }
6138 return D_O_K;
6139 }
6140
6141 enum
6142 {
6143 MENUID_REPLAY_RECORDNEW,
6144 MENUID_REPLAY_STOP,
6145 MENUID_REPLAY_SAVE,
6146 MENUID_REPLAY_SNAP_ALL,
6147 };
6148
1/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351 static NewMenu replay_menu
6149 2808 {
6150
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Record new saves", onToggleRecordingNewSaves, MENUID_REPLAY_RECORDNEW },
6151
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Stop replay", onStopReplayOrRecord, MENUID_REPLAY_STOP },
6152
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Load replay", onLoadReplay },
6153
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Load replay (assert)", onLoadReplayAssert },
6154
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Load replay (update)", onLoadReplayUpdate },
6155
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Save replay", onSaveReplay, MENUID_REPLAY_SAVE },
6156
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Snapshot all frames", onToggleSnapshotAllFrames, MENUID_REPLAY_SNAP_ALL },
6157 };
6158
6159 static DIALOG credits_dlg[] =
6160 {
6161 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6162 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6163 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6164 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6165 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6166 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6167 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6168 };
6169
6170 351 static ListData dmap_list(dmaplist, &font);
6171
6172 static DIALOG goto_dlg[] =
6173 {
6174 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6175 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6176 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6177 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6178 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6179 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6180 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6181 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6182 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6183 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6184 };
6185
6186 int32_t onGoTo()
6187 {
6188 bool music = false;
6189 music = music;
6190 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6191
6192 goto_dlg[0].dp2=get_zc_font(font_lfont);
6193 goto_dlg[4].d2=cheat_goto_dmap;
6194 goto_dlg[6].dp=cheat_goto_screen_str;
6195
6196 clear_keybuf();
6197
6198 large_dialog(goto_dlg);
6199
6200 if(do_zqdialog(goto_dlg,4)==1)
6201 {
6202 // dmap, screen
6203 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6204 };
6205
6206 return D_O_K;
6207 }
6208
6209 int32_t onGoToComplete()
6210 {
6211 if(!Playing)
6212 {
6213 return D_O_K;
6214 }
6215
6216 enter_sys_pal();
6217 music_pause();
6218 pause_all_sfx();
6219 onGoTo();
6220 eat_buttons();
6221
6222 zc_readrawkey(KEY_ESC);
6223
6224 exit_sys_pal();
6225 music_resume();
6226 resume_all_sfx();
6227 return D_O_K;
6228 }
6229
6230 int32_t onCredits()
6231 {
6232 return D_O_K;
6233 }
6234
6235 const char *midilist(int32_t index, int32_t *list_size)
6236 {
6237 if(index<0)
6238 {
6239 *list_size=0;
6240
6241 for(int32_t i=0; i<MAXMIDIS; i++)
6242 if(tunes[i].data)
6243 ++(*list_size);
6244
6245 return NULL;
6246 }
6247
6248 int32_t i=0,m=0;
6249
6250 while(m<=index && i<=MAXMIDIS)
6251 {
6252 if(tunes[i].data)
6253 ++m;
6254
6255 ++i;
6256 }
6257
6258 --i;
6259
6260 if(i==MAXMIDIS && m<index)
6261 return "(null)";
6262
6263 return tunes[i].title;
6264 }
6265
6266 /* ------- MIDI info stuff -------- */
6267
6268 char *text;
6269 midi_info *zmi;
6270 bool dialog_running;
6271 bool listening;
6272
6273 void get_info(int32_t index);
6274
6275 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6276 {
6277 int32_t d2 = d->d2;
6278 int32_t ret = jwin_droplist_proc(msg,d,c);
6279
6280 if(d2!=d->d2)
6281 {
6282 get_info(d->d2);
6283 }
6284
6285 return ret;
6286 }
6287
6288 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6289 {
6290 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6291
6292 int32_t ret = jwin_button_proc(msg,d,c);
6293
6294 if(ret == D_CLOSE)
6295 {
6296 // get current midi index
6297 int32_t index = (d+(d->d1))->d2;
6298 int32_t i=0, m=0;
6299
6300 while(m<=index && i<=MAXMIDIS)
6301 {
6302 if(tunes[i].data)
6303 ++m;
6304
6305 ++i;
6306 }
6307
6308 --i;
6309 jukebox(i);
6310 listening = true;
6311 ret = D_O_K;
6312 }
6313
6314 return ret;
6315 }
6316
6317 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6318 {
6319 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6320
6321 int32_t ret = jwin_button_proc(msg,d,c);
6322
6323 if(ret == D_CLOSE)
6324 {
6325 // get current midi index
6326 int32_t index = (d+(d->d1))->d2;
6327 int32_t i=0, m=0;
6328
6329 while(m<=index && i<=MAXMIDIS)
6330 {
6331 if(tunes[i].data)
6332 ++m;
6333
6334 ++i;
6335 }
6336
6337 --i;
6338
6339 // get file name
6340
6341 int32_t sel=0;
6342 //struct ffblk f;
6343 char title[40] = "Save MIDI: ";
6344 char fname[2048];
6345 memset(fname,0,2048);
6346 static EXT_LIST list[] =
6347 {
6348 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6349 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6350 { NULL, NULL }
6351 };
6352
6353 strcpy(title+11, tunes[i].title);
6354 title[39] = '\0';
6355
6356 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6357 goto done;
6358
6359 if(exists(fname))
6360 {
6361 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6362 goto done;
6363 }
6364
6365 // save midi i
6366
6367 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6368 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6369
6370 done:
6371 chop_path(fname);
6372 ret = D_REDRAW;
6373 }
6374
6375 return ret;
6376 }
6377
6378 351 static ListData midi_list(midilist, &font);
6379
6380 static DIALOG midi_dlg[] =
6381 {
6382 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6383 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6384 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6385 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6386 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6387 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6388 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6389 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6390 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6391 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6392 };
6393
6394 void get_info(int32_t index)
6395 {
6396 int32_t i=0, m=0;
6397
6398 while(m<=index && i<=MAXMIDIS)
6399 {
6400 if(tunes[i].data)
6401 ++m;
6402
6403 ++i;
6404 }
6405
6406 --i;
6407
6408 if(i==MAXMIDIS && m<index)
6409 strcpy(text,"(null)");
6410 else
6411 {
6412 get_midi_info((MIDI*)tunes[i].data,zmi);
6413 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6414 }
6415
6416 midi_dlg[0].dp2=get_zc_font(font_lfont);
6417 midi_dlg[3].dp = text;
6418 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6419 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6420
6421 if(dialog_running)
6422 {
6423 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6424 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6425 }
6426 }
6427
6428 int32_t onMIDICredits()
6429 {
6430 text = (char*)malloc(4096);
6431 zmi = (midi_info*)malloc(sizeof(midi_info));
6432
6433 if(!text || !zmi)
6434 {
6435 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6436 return D_O_K;
6437 }
6438
6439 bool do_pause_midi = midi_pos >= 0 && currmidi;
6440 auto restore_midi = currmidi;
6441 if(do_pause_midi)
6442 {
6443 paused_midi_pos = midi_pos;
6444 stop_midi();
6445 midi_suspended = midissuspHALTED;
6446 }
6447
6448 midi_dlg[0].dp2=get_zc_font(font_lfont);
6449 midi_dlg[2].d1 = 0;
6450 midi_dlg[2].d2 = 0;
6451 midi_dlg[4].flags = D_EXIT;
6452 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6453
6454 listening = false;
6455 dialog_running=false;
6456 get_info(0);
6457
6458 dialog_running=true;
6459
6460 large_dialog(midi_dlg);
6461
6462 do_zqdialog(midi_dlg,0);
6463 dialog_running=false;
6464
6465 if(listening)
6466 music_stop();
6467
6468 if(do_pause_midi)
6469 {
6470 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6471 midi_suspended = midissuspRESUME;
6472 currmidi = restore_midi;
6473 midi_pos = paused_midi_pos;
6474 }
6475
6476 if(text) free(text);
6477 if(zmi) free(zmi);
6478 return D_O_K;
6479 }
6480
6481 int32_t onAbout()
6482 {
6483 char buf1[80]={0};
6484 std::ostringstream oss;
6485 sprintf(buf1,ZC_PLAYER_NAME);
6486 oss << buf1 << '\n';
6487 sprintf(buf1,"Version: %s", getVersionString());
6488 oss << buf1 << '\n';
6489 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6490 oss << buf1 << '\n';
6491 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6492 oss << buf1 << '\n';
6493
6494 InfoDialog("About ZC", oss.str()).show();
6495 return D_O_K;
6496 }
6497
6498 int32_t onQuest()
6499 {
6500 char fname[100];
6501 strcpy(fname, get_filename(qstpath));
6502 quest_dlg[0].dp2=get_zc_font(font_lfont);
6503 quest_dlg[1].dp = fname;
6504
6505 if(QHeader.quest_number==0)
6506 sprintf(str_a,"Custom");
6507 else
6508 sprintf(str_a,"%d",QHeader.quest_number);
6509
6510 sprintf(str_s,"%s",QHeader.getVerStr());
6511
6512 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6513 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6514
6515 large_dialog(quest_dlg);
6516
6517 do_zqdialog(quest_dlg, 0);
6518 return D_O_K;
6519 }
6520
6521 void call_vidmode_dlg();
6522 int32_t onVidMode()
6523 {
6524 call_vidmode_dlg();
6525 return D_O_K;
6526 }
6527
6528 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6529 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6530 //Added an extra statement, so that if the key is cleared to 0, the cleared
6531 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6532
6533 void load_ukeys(int32_t* arr)
6534 {
6535 arr[ukey_a] = Akey;
6536 arr[ukey_b] = Bkey;
6537 arr[ukey_s] = Skey;
6538 arr[ukey_l] = Lkey;
6539 arr[ukey_r] = Rkey;
6540 arr[ukey_p] = Pkey;
6541 arr[ukey_ex1] = Exkey1;
6542 arr[ukey_ex2] = Exkey2;
6543 arr[ukey_ex3] = Exkey3;
6544 arr[ukey_ex4] = Exkey4;
6545 arr[ukey_du] = DUkey;
6546 arr[ukey_dd] = DDkey;
6547 arr[ukey_dl] = DLkey;
6548 arr[ukey_dr] = DRkey;
6549 arr[ukey_mod1a] = cheat_modifier_keys[0];
6550 arr[ukey_mod1b] = cheat_modifier_keys[1];
6551 arr[ukey_mod2a] = cheat_modifier_keys[2];
6552 arr[ukey_mod2b] = cheat_modifier_keys[3];
6553 };
6554
6555 static const char* ukey_names[] = {
6556 "A", "B", "Start", "L", "R", "Map",
6557 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6558 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6559 "Cheat Mod R1", "Cheat Mod R2",
6560 };
6561 std::string get_ukey_name(int32_t k)
6562 {
6563 if (k < num_ukey) return ukey_names[k];
6564 return "";
6565 }
6566
6567 int32_t onKeyboard()
6568 {
6569 int32_t a = Akey;
6570 int32_t b = Bkey;
6571 int32_t s = Skey;
6572 int32_t l = Lkey;
6573 int32_t r = Rkey;
6574 int32_t p = Pkey;
6575 int32_t ex1 = Exkey1;
6576 int32_t ex2 = Exkey2;
6577 int32_t ex3 = Exkey3;
6578 int32_t ex4 = Exkey4;
6579 int32_t du = DUkey;
6580 int32_t dd = DDkey;
6581 int32_t dl = DLkey;
6582 int32_t dr = DRkey;
6583 int32_t mod1a = cheat_modifier_keys[0];
6584 int32_t mod1b = cheat_modifier_keys[1];
6585 int32_t mod2a = cheat_modifier_keys[2];
6586 int32_t mod2b = cheat_modifier_keys[3];
6587 bool done=false;
6588 int32_t ret;
6589
6590 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6591
6592 large_dialog(keyboard_control_dlg);
6593
6594 while(!done)
6595 {
6596 ret = do_zqdialog(keyboard_control_dlg,3);
6597
6598 if(ret==3) // OK
6599 {
6600 int32_t ukeys[num_ukey];
6601 load_ukeys(ukeys);
6602 std::vector<std::string> uniqueError;
6603 for(int32_t q = 0; q < num_ukey; ++q)
6604 {
6605 for(int32_t p = q+1; p < num_ukey; ++p)
6606 {
6607 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6608 {
6609 char buf[64];
6610 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6611 std::string str(buf);
6612 uniqueError.push_back(str);
6613 }
6614 }
6615 }
6616 if(uniqueError.size() == 0)
6617 {
6618 done = true;
6619 save_control_configs(true);
6620 }
6621 else
6622 {
6623 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6624 box_out("Cannot have duplicate keybinds!"); box_eol();
6625 for(std::vector<std::string>::iterator it = uniqueError.begin();
6626 it != uniqueError.end(); ++it)
6627 {
6628 box_out((*it).c_str()); box_eol();
6629 }
6630 box_end(true);
6631 }
6632 }
6633 else // Cancel
6634 {
6635 Akey = a;
6636 Bkey = b;
6637 Skey = s;
6638 Lkey = l;
6639 Rkey = r;
6640 Pkey = p;
6641 Exkey1 = ex1;
6642 Exkey2 = ex2;
6643 Exkey3 = ex3;
6644 Exkey4 = ex4;
6645 DUkey = du;
6646 DDkey = dd;
6647 DLkey = dl;
6648 DRkey = dr;
6649 cheat_modifier_keys[0] = mod1a;
6650 cheat_modifier_keys[1] = mod1b;
6651 cheat_modifier_keys[2] = mod2a;
6652 cheat_modifier_keys[3] = mod2b;
6653
6654 done=true;
6655 }
6656
6657 rest(1);
6658 }
6659
6660 return D_O_K;
6661 }
6662
6663 int32_t onGamepad()
6664 {
6665 if (al_get_num_joysticks() == 0)
6666 {
6667 InfoDialog("ZC", "No gamepads detected.").show();
6668 return D_O_K;
6669 }
6670
6671 int32_t a = Abtn;
6672 int32_t b = Bbtn;
6673 int32_t s = Sbtn;
6674 int32_t l = Lbtn;
6675 int32_t r = Rbtn;
6676 int32_t m = Mbtn;
6677 int32_t p = Pbtn;
6678 int32_t ex1 = Exbtn1;
6679 int32_t ex2 = Exbtn2;
6680 int32_t ex3 = Exbtn3;
6681 int32_t ex4 = Exbtn4;
6682 int32_t up = DUbtn;
6683 int32_t down = DDbtn;
6684 int32_t left = DLbtn;
6685 int32_t right = DRbtn;
6686 int32_t joy = joystick_index;
6687 int32_t stick_1 = js_stick_1_x_stick;
6688 int32_t stick_2 = js_stick_2_x_stick;
6689
6690 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6691 if(analog_movement)
6692 gamepad_dlg[56].flags|=D_SELECTED;
6693 else
6694 gamepad_dlg[56].flags&=~D_SELECTED;
6695
6696 // TODO: should use controller device GUID or name instead of index, otherwise this value is not
6697 // consistent unless exact same number of joysticks is always connected. Name is problematic b/c
6698 // xinput driver doesn't actually get a name (at least, doesn't for my Xbox controller).
6699 // TODO: should store gamepad control mappings per-controller, otherwise switching joystick
6700 // requires remapping every time.
6701 if (joystick_index >= al_get_num_joysticks())
6702 joystick_index = 0;
6703 gamepad_dlg[61].d2 = joystick_index;
6704
6705 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6706 if (!gamepad_dlg_cur_joystick)
6707 {
6708 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6709 return D_CLOSE;
6710 }
6711
6712 large_dialog(gamepad_dlg);
6713
6714 int32_t ret = do_zqdialog(gamepad_dlg,4);
6715
6716 if(ret == 4) //OK
6717 {
6718 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6719 joystick_index = gamepad_dlg[61].d2;
6720 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6721 if (!gamepad_dlg_cur_joystick)
6722 {
6723 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6724 return D_CLOSE;
6725 }
6726 js_stick_1_y_stick = js_stick_1_x_stick;
6727 js_stick_2_y_stick = js_stick_2_x_stick;
6728 save_control_configs(false);
6729 }
6730 else //Cancel
6731 {
6732 Abtn = a;
6733 Bbtn = b;
6734 Sbtn = s;
6735 Lbtn = l;
6736 Rbtn = r;
6737 Mbtn = m;
6738 Pbtn = p;
6739 Exbtn1 = ex1;
6740 Exbtn2 = ex2;
6741 Exbtn3 = ex3;
6742 Exbtn4 = ex4;
6743 DUbtn = up;
6744 DDbtn = down;
6745 DLbtn = left;
6746 DRbtn = right;
6747 joystick_index = joy;
6748 js_stick_1_x_stick = stick_1;
6749 js_stick_2_x_stick = stick_2;
6750 }
6751
6752 return D_O_K;
6753 }
6754
6755 int32_t onCheatKeys()
6756 {
6757 int32_t oldcheats[Cheat::Last][2];
6758 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6759
6760 bool done=false;
6761
6762 while(!done)
6763 {
6764 bool confirm = false;
6765 CheatKeysDialog(&confirm).show();
6766 if(confirm) // OK
6767 {
6768 std::vector<std::string> uniqueError;
6769 char buf[512];
6770 for(size_t q = 1; q < Cheat::Last; ++q)
6771 {
6772 if(cheatkeys[q][1] && !cheatkeys[q][0])
6773 {
6774 cheatkeys[q][0] = cheatkeys[q][1];
6775 cheatkeys[q][1] = 0;
6776 }
6777 }
6778 for(size_t q = 1; q < Cheat::Last; ++q)
6779 {
6780 if(!bindable_cheat((Cheat)q)) continue;
6781 for(size_t p = q+1; p < Cheat::Last; ++p)
6782 {
6783 if(!bindable_cheat((Cheat)p)) continue;
6784 for(size_t q2 = 0; q2 <= 1; ++q2)
6785 for(size_t p2 = 0; p2 <= 1; ++p2)
6786 {
6787 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6788 {
6789 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6790 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6791 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6792 get_keystr(cheatkeys[q][q2])));
6793 }
6794 }
6795 }
6796 }
6797 if(uniqueError.size() == 0)
6798 {
6799 done = true;
6800 save_cheatkeys();
6801 }
6802 else
6803 {
6804 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6805 box_out("Cannot have duplicate keybinds!"); box_eol();
6806 for(std::vector<std::string>::iterator it = uniqueError.begin();
6807 it != uniqueError.end(); ++it)
6808 {
6809 box_out((*it).c_str()); box_eol();
6810 }
6811 box_end(true);
6812 }
6813 }
6814 else // Cancel
6815 {
6816 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6817 done=true;
6818 }
6819 rest(1);
6820 }
6821
6822 return D_O_K;
6823 }
6824
6825 int32_t onSound()
6826 {
6827 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6828 {
6829 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6830 {
6831 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6832 }
6833 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6834 {
6835 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6836 }
6837 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6838 {
6839 emusic_volume = (int32_t)FFCore.usr_music_volume;
6840 }
6841 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6842 {
6843 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6844 }
6845 }
6846 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6847 {
6848 pan_style = (int32_t)FFCore.usr_panstyle;
6849 }
6850
6851 int32_t m = midi_volume;
6852 int32_t e = emusic_volume;
6853 int32_t s = sfx_volume;
6854 int32_t p = pan_style;
6855 pan_style = vbound(pan_style,0,3);
6856
6857 sound_dlg[0].dp2=get_zc_font(font_lfont);
6858
6859 large_dialog(sound_dlg);
6860
6861 midi_dp[1] = sound_dlg[6].x;
6862 midi_dp[2] = sound_dlg[6].y;
6863 emus_dp[1] = sound_dlg[8].x;
6864 emus_dp[2] = sound_dlg[8].y;
6865 sfx_dp[1] = sound_dlg[10].x;
6866 sfx_dp[2] = sound_dlg[10].y;
6867 pan_dp[1] = sound_dlg[11].x;
6868 pan_dp[2] = sound_dlg[11].y;
6869 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6870 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6871 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6872 sound_dlg[20].d2 = pan_style;
6873
6874 int32_t ret = do_zqdialog(sound_dlg,1);
6875
6876 if(ret==2)
6877 {
6878 master_volume(digi_volume,midi_volume);
6879 if (zcmusic)
6880 zcmusic_set_volume(zcmusic, emusic_volume);
6881
6882 int32_t temp_volume = sfx_volume;
6883 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
6884 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6885 for(int32_t i=0; i<WAV_COUNT; ++i)
6886 {
6887 if(sfx_voice[i] >= 0)
6888 voice_set_volume(sfx_voice[i], temp_volume);
6889 }
6890 zc_set_config(sfx_sect,"midi",midi_volume);
6891 zc_set_config(sfx_sect,"sfx",sfx_volume);
6892 zc_set_config(sfx_sect,"emusic",emusic_volume);
6893 zc_set_config(sfx_sect,"pan",pan_style);
6894 }
6895 else
6896 {
6897 midi_volume = m;
6898 emusic_volume = e;
6899 sfx_volume = s;
6900 pan_style = p;
6901 }
6902
6903 return D_O_K;
6904 }
6905
6906 int32_t queding(char const* s1, char const* s2, char const* s3)
6907 {
6908 return jwin_alert("ZQuest Classic",s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6909 }
6910
6911 int32_t onQuit()
6912 {
6913 if(Playing)
6914 {
6915 int32_t ret=0;
6916
6917 if(get_qr(qr_NOCONTINUE))
6918 {
6919 if(standalone_mode)
6920 {
6921 ret=queding("End current game?",
6922 "The continue screen is disabled; the game",
6923 "will be reloaded from the last save.");
6924 }
6925 else
6926 {
6927 ret=queding("End current game?",
6928 "The continue screen is disabled. You will",
6929 "be returned to the file select screen.");
6930 }
6931 }
6932 else
6933 ret=queding("End current game?",NULL,NULL);
6934
6935 if(ret==1)
6936 {
6937 disableClickToFreeze=false;
6938 Quit=qQUIT;
6939
6940 // Trying to evade a door repair charge?
6941 if(repaircharge)
6942 {
6943 game->change_drupy(-repaircharge);
6944 repaircharge=0;
6945 }
6946
6947 return D_CLOSE;
6948 }
6949 }
6950
6951 return D_O_K;
6952 }
6953
6954 int32_t onTryQuitMenu()
6955 {
6956 return onTryQuit(true);
6957 }
6958
6959 int32_t onTryQuit(bool inMenu)
6960 {
6961 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
6962 {
6963 if(active_cutscene.can_f6())
6964 {
6965 if(get_qr(qr_OLD_F6))
6966 {
6967 if(inMenu) onQuit();
6968 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
6969 }
6970 else
6971 {
6972 disableClickToFreeze=false;
6973 GameFlags |= GAMEFLAG_TRYQUIT;
6974 }
6975 return D_CLOSE;
6976 }
6977 else active_cutscene.error();
6978 }
6979
6980 return D_O_K;
6981 }
6982
6983 int32_t onReset()
6984 {
6985 if(queding(" Reset system? ",NULL,NULL)==1)
6986 {
6987 disableClickToFreeze=false;
6988 Quit=qRESET;
6989 replay_quit();
6990 return D_CLOSE;
6991 }
6992
6993 return D_O_K;
6994 }
6995
6996 int32_t onExit()
6997 {
6998 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
6999 {
7000 Quit=qEXIT;
7001 return D_CLOSE;
7002 }
7003
7004 return D_O_K;
7005 }
7006
7007 int32_t onDebug()
7008 {
7009 if(debug_enabled)
7010 set_debug(!get_debug());
7011 return D_O_K;
7012 }
7013
7014 int32_t onHeartBeep()
7015 {
7016 heart_beep=!heart_beep;
7017 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7018 return D_O_K;
7019 }
7020
7021 int32_t onSaveIndicator()
7022 {
7023 use_save_indicator = use_save_indicator ? 0 : 1;
7024 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7025 return D_O_K;
7026 }
7027
7028 int32_t onEpilepsy()
7029 {
7030 if(jwin_alert3(
7031 "Epilepsy Flash Reduction",
7032 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7033 "Disabling this will restore standard flash and wavy behaviour.",
7034 "Proceed?",
7035 "&Yes",
7036 "&No",
7037 NULL,
7038 'y',
7039 'n',
7040 0,
7041 get_zc_font(font_lfont)) == 1)
7042 {
7043 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7044 zc_set_config("zeldadx","checked_epilepsy",1);
7045 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7046 }
7047 return D_O_K;
7048 }
7049
7050 bool rc = false;
7051
7052 static DIALOG getnum_dlg[] =
7053 {
7054 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7055 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7056 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7057 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7058 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7059 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7060 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7061 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7062 };
7063
7064 int32_t getnumber(const char *prompt,int32_t initialval)
7065 {
7066 char buf[20];
7067 sprintf(buf,"%d",initialval);
7068 getnum_dlg[0].dp=(void *)prompt;
7069 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7070 getnum_dlg[2].dp=buf;
7071
7072 large_dialog(getnum_dlg);
7073
7074 if(do_zqdialog(getnum_dlg,2)==3)
7075 return atoi(buf);
7076
7077 return initialval;
7078 }
7079
7080 int32_t onLife()
7081 {
7082 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7083 cheats_enqueue(Cheat::Life, value);
7084 return D_O_K;
7085 }
7086
7087 int32_t onHeartC()
7088 {
7089 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7090 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7091 cheats_enqueue(Cheat::MaxLife, max_life);
7092 cheats_enqueue(Cheat::Life, life);
7093 return D_O_K;
7094 }
7095
7096 int32_t onMagicC()
7097 {
7098 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7099 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,max_magic/game->get_mp_per_block())*game->get_mp_per_block();
7100 cheats_enqueue(Cheat::MaxMagic, max_magic);
7101 cheats_enqueue(Cheat::Magic, magic);
7102 return D_O_K;
7103 }
7104
7105 int32_t onRupies()
7106 {
7107 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7108 cheats_enqueue(Cheat::Rupies, value);
7109 return D_O_K;
7110 }
7111
7112 int32_t onMaxBombs()
7113 {
7114 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7115 cheats_enqueue(Cheat::MaxBombs, value);
7116 cheats_enqueue(Cheat::Bombs, value);
7117 return D_O_K;
7118 }
7119
7120 int32_t onRefillLife()
7121 {
7122 cheats_enqueue(Cheat::Life, game->get_maxlife());
7123 return D_O_K;
7124 }
7125 int32_t onRefillMagic()
7126 {
7127 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7128 return D_O_K;
7129 }
7130 int32_t onClock()
7131 {
7132 cheats_enqueue(Cheat::Clock);
7133 return D_O_K;
7134 }
7135
7136 int32_t onQstPath()
7137 {
7138 char path[2048];
7139
7140 chop_path(qstdir);
7141 strcpy(path,qstdir);
7142
7143 go();
7144
7145 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7146 {
7147 chop_path(path);
7148 fix_filename_case(path);
7149 fix_filename_slashes(path);
7150 strcpy(qstdir,path);
7151 strcpy(qstpath,qstdir);
7152 zc_set_config("zeldadx","quest_dir",qstdir);
7153 flush_config_file();
7154 }
7155
7156 comeback();
7157 return D_O_K;
7158 }
7159
7160 #include "dialog/cheat_dialog.h"
7161 int32_t onCheat()
7162 {
7163 call_setcheat_dialog();
7164 game->set_cheat(maxcheat);
7165 if(cheat) game->did_cheat(true);
7166 return D_O_K;
7167 }
7168
7169 int32_t onCheatRupies()
7170 {
7171 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7172 return D_O_K;
7173 }
7174
7175 int32_t onCheatArrows()
7176 {
7177 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7178 return D_O_K;
7179 }
7180
7181 int32_t onCheatBombs()
7182 {
7183 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7184 return D_O_K;
7185 }
7186
7187 // *** screen saver
7188
7189 18318803 int32_t after_time()
7190 {
7191
1/2
✓ Branch 0 taken 18318803 times.
✗ Branch 1 not taken.
18318803 if(ss_enable == 0)
7192 return INT_MAX;
7193
7194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318803 times.
18318803 if(ss_after <= 0)
7195 return 5 * 60;
7196
7197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318803 times.
18318803 if(ss_after <= 3)
7198 return ss_after * 15 * 60;
7199
7200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318803 times.
18318803 if(ss_after <= 13)
7201 return (ss_after - 3) * 60 * 60;
7202
7203 18318803 return MAX_IDLE + 1;
7204 18318803 }
7205
7206 static const char *after_str[15] =
7207 {
7208 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7209 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7210 "Never"
7211 };
7212
7213 const char *after_list(int32_t index, int32_t *list_size)
7214 {
7215 if(index < 0)
7216 {
7217 *list_size = 15;
7218 return NULL;
7219 }
7220
7221 return after_str[index];
7222 }
7223
7224 351 static ListData after__list(after_list, &font);
7225
7226 static DIALOG scrsaver_dlg[] =
7227 {
7228 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7229 351 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7230 351 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7231 351 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7232 351 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7233 351 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7234 351 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7235 351 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7236 351 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7237 351 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7238 351 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7239 351 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7240 351 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7241 351 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7242 };
7243
7244 int32_t onScreenSaver()
7245 {
7246 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7247 int32_t oldcfgs[3];
7248 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7249 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7250 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7251
7252 large_dialog(scrsaver_dlg);
7253
7254 int32_t ret = do_zqdialog(scrsaver_dlg,-1);
7255
7256 if(ret == 8 || ret == 9)
7257 {
7258 ss_after = scrsaver_dlg[5].d1;
7259 ss_speed = scrsaver_dlg[6].d2;
7260 ss_density = scrsaver_dlg[7].d2;
7261 if(oldcfgs[0] != ss_after)
7262 zc_set_config(cfg_sect,"ss_after",ss_after);
7263 if(oldcfgs[1] != ss_speed)
7264 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7265 if(oldcfgs[2] != ss_density)
7266 zc_set_config(cfg_sect,"ss_density",ss_density);
7267 }
7268
7269 if(ret == 9)
7270 // preview Screen Saver
7271 {
7272 clear_keybuf();
7273 Matrix(ss_speed, ss_density, 30);
7274 system_pal(true);
7275 sys_mouse();
7276 }
7277
7278 return D_O_K;
7279 }
7280
7281 /***** Menus *****/
7282
7283 enum
7284 {
7285 MENUID_GAME_LOADQUEST,
7286 MENUID_GAME_ENDGAME,
7287 };
7288
1/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351 static NewMenu game_menu
7289 2808 {
7290
3/6
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✗ Branch 5 not taken.
351 { "&Continue","ESC", onContinue },
7291
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 {},
7292
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "L&oad Quest...", onCustomGame, MENUID_GAME_LOADQUEST },
7293
3/6
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✗ Branch 5 not taken.
351 { "&End Game","F6", onTryQuitMenu, MENUID_GAME_ENDGAME },
7294
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 {},
7295 #ifdef __EMSCRIPTEN__
7296 { "&Reset","F7", onReset },
7297 #elif defined(ALLEGRO_MACOSX)
7298 { "&Reset","F7", onReset },
7299 { "&Quit","F8", onExit },
7300 #else
7301
3/6
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✗ Branch 5 not taken.
351 { "&Reset","F9", onReset },
7302
3/6
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✗ Branch 5 not taken.
351 { "&Quit","F10", onExit },
7303 #endif
7304 };
7305
7306
1/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351 static NewMenu snapshot_format_menu
7307 2457 {
7308
4/8
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 351 times.
✗ Branch 7 not taken.
351 { "&BMP", std::bind(onSetSnapshotFormat, ssfmtBMP) },
7309
4/8
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 351 times.
✗ Branch 7 not taken.
351 { "&GIF", std::bind(onSetSnapshotFormat, ssfmtGIF) },
7310
4/8
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 351 times.
✗ Branch 7 not taken.
351 { "&JPG", std::bind(onSetSnapshotFormat, ssfmtJPG) },
7311
4/8
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 351 times.
✗ Branch 7 not taken.
351 { "&PNG", std::bind(onSetSnapshotFormat, ssfmtPNG) },
7312
4/8
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 351 times.
✗ Branch 7 not taken.
351 { "PC&X", std::bind(onSetSnapshotFormat, ssfmtPCX) },
7313
4/8
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 351 times.
✗ Branch 7 not taken.
351 { "&TGA", std::bind(onSetSnapshotFormat, ssfmtTGA) },
7314 };
7315
7316
1/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351 static NewMenu controls_menu
7317 1404 {
7318
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Key&board...", onKeyboard },
7319
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Gamepad...", onGamepad },
7320
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Cheat Keys...", onCheatKeys },
7321 };
7322
7323
1/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351 static NewMenu name_entry_mode_menu
7324 1404 {
7325
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Keyboard", onKeyboardEntry },
7326
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Letter Grid", onLetterGridEntry },
7327
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Extended Letter Grid", onExtLetterGridEntry },
7328 };
7329
7330 static void set_controls_menu_active()
7331 {
7332
7333 }
7334
7335 enum
7336 {
7337 MENUID_WINDOW_LOCK_ASPECT,
7338 MENUID_WINDOW_LOCK_INTSCALE,
7339 MENUID_WINDOW_SAVE_SIZE,
7340 MENUID_WINDOW_SAVE_POS,
7341 MENUID_WINDOW_STRETCH,
7342 };
7343
1/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351 static NewMenu window_menu
7344 2106 {
7345
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Lock Aspect Ratio", onDragAspect, MENUID_WINDOW_LOCK_ASPECT },
7346
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Lock Integer Scale", onIntegerScaling, MENUID_WINDOW_LOCK_INTSCALE },
7347
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Save Size Changes", onSaveDragResize, MENUID_WINDOW_SAVE_SIZE },
7348
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Save Position Changes", onWinPosSave, MENUID_WINDOW_SAVE_POS },
7349
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Stretch Game Area", onStretchGame, MENUID_WINDOW_STRETCH },
7350 };
7351 void call_zc_options_dlg();
7352 enum
7353 {
7354 MENUID_OPTIONS_PAUSE_BG,
7355 MENUID_OPTIONS_EPILEPSYPROT,
7356 };
7357
1/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351 static NewMenu options_menu
7358 2457 {
7359
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Name &Entry Mode", &name_entry_mode_menu },
7360
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "S&napshot Format", &snapshot_format_menu },
7361
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Window Settings", &window_menu },
7362
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Epilepsy Flash Reduction", onEpilepsy, MENUID_OPTIONS_EPILEPSYPROT },
7363
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Pause In Background", onPauseInBackground, MENUID_OPTIONS_PAUSE_BG },
7364
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "More Options", call_zc_options_dlg },
7365 };
7366 enum
7367 {
7368 MENUID_SETTINGS_CONTROLS,
7369 MENUID_SETTINGS_CAPFPS,
7370 MENUID_SETTINGS_SHOWFPS,
7371 MENUID_SETTINGS_SHOWTIME,
7372 MENUID_SETTINGS_CLICK_FREEZE,
7373 MENUID_SETTINGS_TRANSLAYERS,
7374 MENUID_SETTINGS_NESQUIT,
7375 MENUID_SETTINGS_VOLKEYS,
7376 MENUID_SETTINGS_HEARTBEEP,
7377 MENUID_SETTINGS_SAVEINDICATOR,
7378 MENUID_SETTINGS_DEBUG,
7379 };
7380
1/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351 static NewMenu settings_menu
7381 5967 {
7382
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Sound...", onSound },
7383
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "C&ontrols", &controls_menu, MENUID_SETTINGS_CONTROLS },
7384
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 {},
7385
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Options", &options_menu },
7386
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 {},
7387
3/6
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✗ Branch 5 not taken.
351 { "&Cap FPS","F1", onThrottleFPS, MENUID_SETTINGS_CAPFPS },
7388
3/6
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✗ Branch 5 not taken.
351 { "Show &FPS","F2", onShowFPS, MENUID_SETTINGS_SHOWFPS },
7389
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Show &Time", onShowTime, MENUID_SETTINGS_SHOWTIME },
7390
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Click to Freeze", onClickToFreeze, MENUID_SETTINGS_CLICK_FREEZE },
7391
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Cont. &Heart Beep", onHeartBeep, MENUID_SETTINGS_HEARTBEEP },
7392
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Show Trans. &Layers", onTransLayers, MENUID_SETTINGS_TRANSLAYERS },
7393
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Up+A+B To &Quit", onNESquit, MENUID_SETTINGS_NESQUIT },
7394
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Volume &Keys", onVolKeys, MENUID_SETTINGS_VOLKEYS },
7395
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Sa&ve Indicator", onSaveIndicator, MENUID_SETTINGS_SAVEINDICATOR },
7396
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 {},
7397
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Debu&g", onDebug, MENUID_SETTINGS_DEBUG },
7398 };
7399
7400 enum
7401 {
7402 MENUID_MISC_FULLSCREEN,
7403 MENUID_MISC_VIDMODE,
7404 MENUID_MISC_QUEST_INFO,
7405 MENUID_MISC_QUEST_DIR,
7406 MENUID_MISC_CONSOLE,
7407 MENUID_MISC_CLEAR_CONSOLE_ON_LOAD,
7408 };
7409
1/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351 static NewMenu misc_menu
7410 5265 {
7411
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&About...", onAbout },
7412 // TODO: re-enable, but: 1) do not use a bitmap thing that is hard to update 2) update names and 3) don't use the Z-word.
7413 // { "&Credits...", onCredits },
7414
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Fullscreen", onFullscreenMenu, MENUID_MISC_FULLSCREEN },
7415
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Video Mode...", onVidMode, MENUID_MISC_VIDMODE },
7416
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 {},
7417
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Quest Info...", onQuest, MENUID_MISC_QUEST_INFO },
7418
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Quest &MIDI Info...", onMIDICredits },
7419
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Quest &Directory...", onQstPath, MENUID_MISC_QUEST_DIR },
7420
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 {},
7421
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Take &Snapshot F12", onSnapshot },
7422
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Sc&reen Saver...", onScreenSaver },
7423
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Save ZC Configuration", OnSaveZCConfig },
7424
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Show Console", onConsole, MENUID_MISC_CONSOLE },
7425
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Clear Console on Qst Load", onClrConsoleOnLoad, MENUID_MISC_CLEAR_CONSOLE_ON_LOAD },
7426
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Clear Directory Cache", OnnClearQuestDir },
7427 };
7428
7429 enum
7430 {
7431 MENUID_REFILL_ARROWS,
7432 };
7433
1/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351 static NewMenu refill_menu
7434 2106 {
7435
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Life", onRefillLife },
7436
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Magic", onRefillMagic },
7437
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Bombs", onCheatBombs },
7438
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Rupees", onCheatRupies },
7439
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Arrows", onCheatArrows, MENUID_REFILL_ARROWS },
7440 };
7441
7442 enum
7443 {
7444 MENUID_SHOW_L0,
7445 MENUID_SHOW_L1,
7446 MENUID_SHOW_L2,
7447 MENUID_SHOW_L3,
7448 MENUID_SHOW_L4,
7449 MENUID_SHOW_L5,
7450 MENUID_SHOW_L6,
7451 MENUID_SHOW_OVER,
7452 MENUID_SHOW_PUSH,
7453 MENUID_SHOW_FFC,
7454 MENUID_SHOW_SPR,
7455 MENUID_SHOW_SCRIPTNAME,
7456 MENUID_SHOW_SOLIDITY,
7457 MENUID_SHOW_HITBOX,
7458 MENUID_SHOW_EFFECT,
7459 };
7460
1/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351 static NewMenu show_menu
7461 6669 {
7462
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Combos", onShowLayer0, MENUID_SHOW_L0 },
7463
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Layer 1", onShowLayer1, MENUID_SHOW_L1 },
7464
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Layer 2", onShowLayer2, MENUID_SHOW_L2 },
7465
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Layer 3", onShowLayer3, MENUID_SHOW_L3 },
7466
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Layer 4", onShowLayer4, MENUID_SHOW_L4 },
7467
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Layer 5", onShowLayer5, MENUID_SHOW_L5 },
7468
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Layer 6", onShowLayer6, MENUID_SHOW_L6 },
7469
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Overhead Combos", onShowLayerO, MENUID_SHOW_OVER },
7470
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Push Blocks", onShowLayerP, MENUID_SHOW_PUSH },
7471
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Freeform Combos", onShowLayerF, MENUID_SHOW_FFC },
7472
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Sprites", onShowLayerS, MENUID_SHOW_SPR },
7473
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 {},
7474
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Current FFC Scripts", onShowFFScripts, MENUID_SHOW_SCRIPTNAME },
7475
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 {},
7476
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Walkability", onShowLayerW, MENUID_SHOW_SOLIDITY },
7477
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Hitboxes", onShowHitboxes, MENUID_SHOW_HITBOX },
7478
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Effects", onShowLayerE, MENUID_SHOW_EFFECT },
7479
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Info Opacity", onShowInfoOpacity },
7480 };
7481
7482 enum
7483 {
7484 MENUID_CHEAT_CHOP_L1,
7485 MENUID_CHEAT_CHOP_L2,
7486 MENUID_CHEAT_CHOP_L3,
7487 MENUID_CHEAT_CHOP_L4,
7488 MENUID_CHEAT_INVULN,
7489 MENUID_CHEAT_NOCLIP,
7490 MENUID_CHEAT_IGNORESV,
7491 MENUID_CHEAT_GOFAST,
7492 };
7493
1/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351 static NewMenu cheat_menu
7494 5967 {
7495
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Set &Cheat", onCheat },
7496
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 { MENUID_CHEAT_CHOP_L1 },
7497
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Re&fill", &refill_menu },
7498
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 { MENUID_CHEAT_CHOP_L2 },
7499
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Invincible", onClock, MENUID_CHEAT_INVULN },
7500
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Ma&x Bombs...", onMaxBombs },
7501
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Heart Containers...", onHeartC },
7502
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Magic Containers...", onMagicC },
7503
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 { MENUID_CHEAT_CHOP_L3 },
7504
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Player Data...", onCheatConsole },
7505
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 { MENUID_CHEAT_CHOP_L4 },
7506
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Walk Through &Walls", onNoWalls, MENUID_CHEAT_NOCLIP },
7507
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Player Ignores Side&view", onIgnoreSideview, MENUID_CHEAT_IGNORESV },
7508
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Quick Movement", onGoFast, MENUID_CHEAT_GOFAST },
7509
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Kill All Enemies", onKillCheat },
7510
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Trigger &Secrets", onSecretsCheat },
7511
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Trigger Secrets Perm", onSecretsCheatPerm },
7512
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Show/Hide Layer", &show_menu },
7513
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "Toggle &Light", onLightSwitch },
7514
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Goto Location...", onGoTo },
7515 };
7516
7517 #if DEVLEVEL > 0
7518 int32_t devLogging();
7519 int32_t devDebug();
7520 int32_t devTimestmp();
7521 #if DEVLEVEL > 1
7522 int32_t setCheat();
7523 #endif //DEVLEVEL > 1
7524 enum
7525 {
7526 MENUID_DEV_LOGGING,
7527 MENUID_DEV_DEBUG,
7528 MENUID_DEV_TIMESTAMP,
7529 MENUID_DEV_SETCHEAT,
7530 };
7531 static NewMenu dev_menu
7532 {
7533 { "&Force Error Log", devLogging, MENUID_DEV_LOGGING },
7534 // { "&Extra Debug Log", devDebug, MENUID_DEV_DEBUG },
7535 { "&Timestamp Log", devTimestmp, MENUID_DEV_TIMESTAMP },
7536 #if DEVLEVEL > 1
7537 {},
7538 { "Set &Cheat", setCheat, MENUID_DEV_SETCHEAT },
7539 #endif //DEVLEVEL > 1
7540 };
7541 int32_t devLogging()
7542 {
7543 dev_logging = !dev_logging;
7544 dev_menu.select_uid(MENUID_DEV_LOGGING, dev_logging);
7545 return D_O_K;
7546 }
7547 // int32_t devDebug()
7548 // {
7549 // dev_debug = !dev_debug;
7550 // dev_menu.select_uid(MENUID_DEV_DEBUG, dev_debug);
7551 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7552 // return D_O_K;
7553 // }
7554 int32_t devTimestmp()
7555 {
7556 dev_timestmp = !dev_timestmp;
7557 dev_menu.select_uid(MENUID_DEV_TIMESTAMP, dev_timestmp);
7558 return D_O_K;
7559 }
7560 #if DEVLEVEL > 1
7561 int32_t setCheat()
7562 {
7563 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7564 return D_O_K;
7565 }
7566 #endif //DEVLEVEL > 1
7567 #endif //DEVLEVEL > 0
7568
7569 enum
7570 {
7571 MENUID_PLAYER_CHEAT,
7572 };
7573
1/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
351 TopMenu the_player_menu
7574 2106 {
7575
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Game", &game_menu },
7576
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Settings", &settings_menu },
7577
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Cheat", &cheat_menu, MENUID_PLAYER_CHEAT, true },
7578
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&Replay", &replay_menu },
7579
2/4
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 { "&ZC", &misc_menu },
7580 #if DEVLEVEL > 0
7581 { "&Dev", &dev_menu },
7582 #endif
7583 };
7584
7585 int32_t onPauseInBackground()
7586 {
7587 if(jwin_alert3(
7588 "Toggle Pause In Background",
7589 "This action will change whether ZC Player pauses when the window loses focus.",
7590 "",
7591 "Proceed?",
7592 "&Yes",
7593 "&No",
7594 NULL,
7595 'y',
7596 'n',
7597 0,
7598 get_zc_font(font_lfont)) == 1)
7599 {
7600 pause_in_background = pause_in_background ? 0 : 1;
7601 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7602 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7603 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7604 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7605 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7606 }
7607 options_menu.select_uid(MENUID_OPTIONS_PAUSE_BG, pause_in_background);
7608 return D_O_K;
7609 }
7610
7611 int32_t onKeyboardEntry()
7612 {
7613 NameEntryMode=0;
7614 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7615 return D_O_K;
7616 }
7617
7618 int32_t onLetterGridEntry()
7619 {
7620 NameEntryMode=1;
7621 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7622 return D_O_K;
7623 }
7624
7625 int32_t onExtLetterGridEntry()
7626 {
7627 NameEntryMode=2;
7628 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7629 return D_O_K;
7630 }
7631
7632 static BITMAP* oldscreen;
7633 int32_t onFullscreenMenu()
7634 {
7635 PALETTE oldpal;
7636 get_palette(oldpal);
7637
7638 fullscreen = !fullscreen;
7639 all_toggle_fullscreen(fullscreen);
7640 zc_set_config("zeldadx","fullscreen",fullscreen);
7641
7642 zc_set_palette(oldpal);
7643 gui_mouse_focus=0;
7644 extern int32_t switch_type;
7645 switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7646 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7647 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7648 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7649 misc_menu.select_uid(MENUID_MISC_FULLSCREEN, isFullScreen());
7650 misc_menu.select_uid(MENUID_MISC_VIDMODE, isFullScreen());
7651
7652 return D_O_K;
7653 }
7654
7655 263 void fix_menu()
7656 {
7657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 263 times.
263 if(!debug_enabled)
7658 263 settings_menu.chop_index = 13;
7659 263 }
7660
7661 int32_t onSetSnapshotFormat(SnapshotType format)
7662 {
7663 SnapshotFormat = format;
7664 zc_set_config("zeldadx", "snapshot_format", format);
7665 snapshot_format_menu.select_only_index(format);
7666 return D_O_K;
7667 }
7668
7669
7670 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7671 {
7672 PALETTE tmp;
7673
7674 for(int32_t i=0; i<256; i++)
7675 {
7676 tmp[i].r=r;
7677 tmp[i].g=g;
7678 tmp[i].b=b;
7679 }
7680
7681 fade_interpolate(src,tmp,dest,pos,from,to);
7682 }
7683
7684 88 void system_pal(bool force)
7685 {
7686
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
88 if(is_sys_pal && !force) return;
7687 88 is_sys_pal = true;
7688 88 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7689 88 hw_palette = &syspal;
7690 88 update_hw_pal = true;
7691 88 }
7692
7693 static uint32_t entered_sys_pal = 0;
7694 88 void enter_sys_pal()
7695 {
7696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(is_sys_pal)
7697 {
7698 if(entered_sys_pal)
7699 ++entered_sys_pal;
7700 return;
7701 }
7702 88 sys_mouse();
7703 88 system_pal(true);
7704 88 ++entered_sys_pal;
7705 88 }
7706 88 void exit_sys_pal()
7707 {
7708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(entered_sys_pal)
7709 {
7710
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!--entered_sys_pal)
7711 {
7712 88 game_pal();
7713 88 game_mouse();
7714 88 }
7715 88 }
7716 88 }
7717
7718 void switch_out_callback()
7719 {
7720 if (pause_in_background && !MenuOpen)
7721 {
7722 System();
7723 }
7724 }
7725
7726 void switch_in_callback()
7727 {
7728 }
7729
7730 1139 void game_pal()
7731 {
7732 1139 is_sys_pal = false;
7733 1139 entered_sys_pal = 0;
7734 1139 hw_palette = &RAMpal;
7735 1139 update_hw_pal = true;
7736 1139 }
7737
7738 static char bar_str[] = "";
7739
7740 61 void music_pause()
7741 {
7742 //al_pause_duh(tmplayer);
7743 61 zcmusic_pause(zcmusic, ZCM_PAUSE);
7744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(zcmixer->oldtrack)
7745 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7746 61 zc_midi_pause();
7747 61 }
7748
7749 void music_resume()
7750 {
7751 //al_resume_duh(tmplayer);
7752 zcmusic_pause(zcmusic, ZCM_RESUME);
7753 if (zcmixer->oldtrack)
7754 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7755 zc_midi_resume();
7756 }
7757
7758 7613 void music_stop()
7759 {
7760 //al_stop_duh(tmplayer);
7761 //unload_duh(tmusic);
7762 //tmusic=NULL;
7763 //tmplayer=NULL;
7764 7613 zcmusic_stop(zcmusic);
7765 7613 zcmusic_unload_file(zcmusic);
7766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7613 times.
7613 if (zcmixer->oldtrack)
7767 {
7768 zcmusic_stop(zcmixer->oldtrack);
7769 zcmusic_unload_file(zcmixer->oldtrack);
7770 }
7771 7613 zcmixer->newtrack = NULL;
7772 7613 zc_stop_midi();
7773 7613 currmidi=-1;
7774 7613 }
7775
7776 bool reload_fonts = false;
7777 void System()
7778 {
7779 mouse_down = gui_mouse_b();
7780 music_pause();
7781 pause_all_sfx();
7782 MenuOpen = true;
7783 enter_sys_pal();
7784 // FONT *oldfont=font;
7785 // font=tfont;
7786
7787 misc_menu.select_uid(MENUID_MISC_FULLSCREEN, isFullScreen());
7788 misc_menu.disable_uid(MENUID_MISC_VIDMODE, isFullScreen());
7789
7790 #if DEVLEVEL > 1
7791 dev_menu.disable_uid(MENUID_DEV_SETCHEAT, !Playing);
7792 #endif
7793 game_menu.disable_uid(MENUID_GAME_LOADQUEST, getsaveslot() < 0);
7794 game_menu.disable_uid(MENUID_GAME_ENDGAME, !Playing);
7795 misc_menu.disable_uid(MENUID_MISC_QUEST_INFO, !Playing);
7796 misc_menu.disable_uid(MENUID_MISC_QUEST_DIR, Playing);
7797 clear_keybuf();
7798
7799 clear_bitmap(menu_bmp);
7800 oldscreen = screen;
7801 screen = menu_bmp;
7802
7803 the_player_menu.reset_state();
7804 the_player_menu.position(0, 0);
7805
7806 bool running = true;
7807 bool esc = key[KEY_ESC] || cMbtn();
7808 bool autopop = esc;
7809 do
7810 {
7811 if(reload_fonts)
7812 {
7813 init_custom_fonts();
7814 clear_bitmap(menu_bmp);
7815 broadcast_dialog_message(MSG_DRAW, 0);
7816 reload_fonts = false;
7817 }
7818 if(handle_close_btn_quit())
7819 break;
7820
7821 //update submenus
7822 {
7823 settings_menu.disable_uid(MENUID_SETTINGS_CONTROLS, replay_is_replaying());
7824 settings_menu.select_uid(MENUID_SETTINGS_CAPFPS, Throttlefps);
7825 settings_menu.select_uid(MENUID_SETTINGS_SHOWFPS, ShowFPS);
7826 settings_menu.select_uid(MENUID_SETTINGS_SHOWTIME, ShowGameTime);
7827 settings_menu.select_uid(MENUID_SETTINGS_CLICK_FREEZE, ClickToFreeze);
7828 settings_menu.select_uid(MENUID_SETTINGS_TRANSLAYERS, TransLayers);
7829 settings_menu.select_uid(MENUID_SETTINGS_NESQUIT, NESquit);
7830 settings_menu.select_uid(MENUID_SETTINGS_VOLKEYS, volkeys);
7831
7832 window_menu.select_uid(MENUID_WINDOW_LOCK_ASPECT, DragAspect);
7833 window_menu.select_uid(MENUID_WINDOW_LOCK_INTSCALE, scaleForceInteger);
7834 window_menu.select_uid(MENUID_WINDOW_SAVE_SIZE, SaveDragResize);
7835 window_menu.select_uid(MENUID_WINDOW_SAVE_POS, SaveWinPos);
7836 window_menu.select_uid(MENUID_WINDOW_STRETCH, stretchGame);
7837
7838 options_menu.select_uid(MENUID_OPTIONS_EPILEPSYPROT, epilepsyFlashReduction);
7839 options_menu.select_uid(MENUID_OPTIONS_PAUSE_BG, pause_in_background);
7840
7841 name_entry_mode_menu.select_only_index(NameEntryMode);
7842
7843 misc_menu.select_uid(MENUID_MISC_CONSOLE, console_enabled);
7844 misc_menu.select_uid(MENUID_MISC_CLEAR_CONSOLE_ON_LOAD, clearConsoleOnLoad);
7845
7846 bool nocheat = (replay_is_replaying() || !Playing
7847 || (!maxcheat && !zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7848 the_player_menu.disable_uid(MENUID_PLAYER_CHEAT, nocheat);
7849 refill_menu.disable_uid(MENUID_REFILL_ARROWS, !get_qr(qr_TRUEARROWS));
7850 cheat_menu.chop_index.reset();
7851 if(cheat < 4)
7852 cheat_menu.chop_index = cheat_menu.ind_at(MENUID_CHEAT_CHOP_L1+cheat);
7853 cheat_menu.select_uid(MENUID_CHEAT_INVULN, getClock());
7854 cheat_menu.select_uid(MENUID_CHEAT_NOCLIP, toogam);
7855 cheat_menu.select_uid(MENUID_CHEAT_IGNORESV, ignoreSideview);
7856 cheat_menu.select_uid(MENUID_CHEAT_GOFAST, gofast);
7857
7858 show_menu.select_uid(MENUID_SHOW_L0, show_layer_0);
7859 show_menu.select_uid(MENUID_SHOW_L1, show_layer_1);
7860 show_menu.select_uid(MENUID_SHOW_L2, show_layer_2);
7861 show_menu.select_uid(MENUID_SHOW_L3, show_layer_3);
7862 show_menu.select_uid(MENUID_SHOW_L4, show_layer_4);
7863 show_menu.select_uid(MENUID_SHOW_L5, show_layer_5);
7864 show_menu.select_uid(MENUID_SHOW_L6, show_layer_6);
7865 show_menu.select_uid(MENUID_SHOW_OVER, show_layer_over);
7866 show_menu.select_uid(MENUID_SHOW_PUSH, show_layer_push);
7867 show_menu.select_uid(MENUID_SHOW_SPR, show_sprites);
7868 show_menu.select_uid(MENUID_SHOW_FFC, show_ffcs);
7869 show_menu.select_uid(MENUID_SHOW_SOLIDITY, show_walkflags);
7870 show_menu.select_uid(MENUID_SHOW_SCRIPTNAME, show_ff_scripts);
7871 show_menu.select_uid(MENUID_SHOW_HITBOX, show_hitboxes);
7872 show_menu.select_uid(MENUID_SHOW_EFFECT, show_effectflags);
7873
7874 settings_menu.select_uid(MENUID_SETTINGS_HEARTBEEP, heart_beep);
7875 settings_menu.select_uid(MENUID_SETTINGS_SAVEINDICATOR, use_save_indicator);
7876
7877 replay_menu.by_uid(MENUID_REPLAY_STOP)->text = fmt::format("Stop {}",
7878 replay_get_mode() == ReplayMode::Record ? "recording" : "replaying");
7879
7880 replay_menu.select_uid(MENUID_REPLAY_RECORDNEW, zc_get_config("zeldadx", "replay_new_saves", false));
7881 replay_menu.disable_uid(MENUID_REPLAY_STOP, !replay_is_active());
7882 replay_menu.disable_uid(MENUID_REPLAY_SAVE, replay_get_mode() != ReplayMode::Record);
7883 replay_menu.select_uid(MENUID_REPLAY_SNAP_ALL, replay_is_snapshot_all_frames());
7884
7885 snapshot_format_menu.select_only_index(SnapshotFormat);
7886 }
7887
7888 if(debug_enabled)
7889 settings_menu.select_uid(MENUID_SETTINGS_DEBUG, get_debug());
7890
7891 if(autopop)
7892 clear_keybuf();
7893 the_player_menu.run(true);
7894 if(autopop)
7895 {
7896 the_player_menu.pop_sub(0, &the_player_menu);
7897 the_player_menu.draw(screen, the_player_menu.hovered_ind());
7898 autopop = false;
7899 update_hw_screen(true);
7900 }
7901
7902 update_hw_screen();
7903 throttleFPS(60);
7904
7905 auto mb = gui_mouse_b();
7906 if(XOR(mb, mouse_down))
7907 {
7908 if(!the_player_menu.has_mouse())
7909 if(mb)
7910 break;
7911 mouse_down = mb;
7912 }
7913
7914 if(input_idle(true) > after_time())
7915 // run Screeen Saver
7916 {
7917 // Screen saver enabled for now.
7918 clear_keybuf();
7919 Matrix(ss_speed, ss_density, 0);
7920 system_pal(true);
7921 sys_mouse();
7922 }
7923
7924 poll_keyboard();
7925 if(esc)
7926 {
7927 if(!key[KEY_ESC])
7928 esc = false;
7929 }
7930
7931 if(keypressed() && !CHECK_ALT) //System hotkeys
7932 {
7933 auto c = peekkey();
7934 bool eatkey = true;
7935 switch(c>>8)
7936 {
7937 //Spare keys used by the menu
7938 case KEY_UP:
7939 case KEY_DOWN:
7940 case KEY_LEFT:
7941 case KEY_RIGHT:
7942 eatkey = false;
7943 break;
7944 case KEY_F1:
7945 onThrottleFPS();
7946 break;
7947 case KEY_F2:
7948 onShowFPS();
7949 break;
7950 case KEY_F6:
7951 onTryQuitMenu();
7952 break;
7953 #ifndef ALLEGRO_MACOSX
7954 case KEY_F9:
7955 onReset();
7956 break;
7957 case KEY_F10:
7958 onExit();
7959 break;
7960 #else
7961 case KEY_F7:
7962 onReset();
7963 break;
7964 case KEY_F8:
7965 onExit();
7966 break;
7967 #endif
7968 case KEY_F12:
7969 onSnapshot();
7970 break;
7971 case KEY_TAB:
7972 onDebug();
7973 break;
7974 case KEY_ESC:
7975 if(!esc)
7976 running = false;
7977 break;
7978 }
7979 if(eatkey)
7980 readkey();
7981 }
7982 if(Quit || (GameFlags & GAMEFLAG_TRYQUIT))
7983 break;
7984 }
7985 while(running);
7986
7987 screen = oldscreen;
7988
7989 mouse_down=gui_mouse_b();
7990 MenuOpen = false;
7991 if(Quit)
7992 {
7993 kill_sfx();
7994 music_stop();
7995 update_hw_screen();
7996 }
7997 else
7998 {
7999 music_resume();
8000 resume_all_sfx();
8001
8002 if(rc)
8003 ringcolor(false);
8004 }
8005 exit_sys_pal();
8006
8007 eat_buttons();
8008
8009 rc=false;
8010 clear_keybuf();
8011
8012 zc_init_apply_cheat_delta();
8013 }
8014
8015 263 void fix_dialogs()
8016 {
8017 263 jwin_center_dialog(about_dlg);
8018 263 jwin_center_dialog(gamepad_dlg);
8019 263 jwin_center_dialog(credits_dlg);
8020 263 jwin_center_dialog(gamemode_dlg);
8021 263 jwin_center_dialog(getnum_dlg);
8022 263 jwin_center_dialog(goto_dlg);
8023 263 jwin_center_dialog(keyboard_control_dlg);
8024 263 jwin_center_dialog(midi_dlg);
8025 263 jwin_center_dialog(quest_dlg);
8026 263 jwin_center_dialog(scrsaver_dlg);
8027 263 jwin_center_dialog(sound_dlg);
8028 263 jwin_center_dialog(triforce_dlg);
8029 263 }
8030
8031 /*****************************/
8032 /**** Custom Sound System ****/
8033 /*****************************/
8034
8035 4329 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8036 {
8037
3/4
✓ Branch 0 taken 4329 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4281 times.
✓ Branch 3 taken 48 times.
4329 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8038 }
8039
8040 290 int32_t get_emusic_volume()
8041 {
8042 290 int32_t temp_volume = emusic_volume;
8043
2/4
✓ Branch 0 taken 290 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 290 times.
✗ Branch 3 not taken.
290 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8044 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 if (!zcmusic)
8046 290 return temp_volume;
8047 return (temp_volume * zcmusic->fadevolume) / 10000;
8048 290 }
8049
8050 int32_t get_zcmusicpos()
8051 {
8052 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8053 return debugtracething;
8054 return 0;
8055 }
8056
8057 void set_zcmusicpos(int32_t position)
8058 {
8059 zcmusic_set_curpos(zcmusic, position);
8060 }
8061
8062 void set_zcmusicspeed(int32_t speed)
8063 {
8064 zcmusic_set_speed(zcmusic, speed);
8065 }
8066
8067 int32_t get_zcmusiclen()
8068 {
8069 return zcmusic_get_length(zcmusic);
8070 }
8071
8072 3 void set_zcmusicloop(double start, double end)
8073 {
8074 3 zcmusic_set_loop(zcmusic, start, end);
8075 3 }
8076
8077 64182 void jukebox(int32_t index,int32_t loop)
8078 {
8079
2/2
✓ Branch 0 taken 64156 times.
✓ Branch 1 taken 26 times.
64182 if (is_headless())
8080 64156 return;
8081
8082 26 music_stop();
8083
8084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if(index<0) index=MAXMIDIS-1;
8085
8086
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(index>=MAXMIDIS) index=0;
8087
8088 26 music_stop();
8089
8090 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8091 // stuck notes when a song stops. This fixes it.
8092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if(strcmp(midi_driver->name, "DIGMID")==0)
8093 zc_set_volume(0, 0);
8094
8095 26 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8096 26 zc_play_midi((MIDI*)tunes[index].data,loop);
8097
8098
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(tunes[index].start>0)
8099 zc_midi_seek(tunes[index].start);
8100
8101 26 midi_loop_start = tunes[index].loop_start;
8102 26 midi_loop_end = tunes[index].loop_end;
8103
8104 26 currmidi=index;
8105 26 master_volume(digi_volume, midi_volume);
8106 //midi_paused=false;
8107 64182 }
8108
8109 64193 void jukebox(int32_t index)
8110 {
8111
1/2
✓ Branch 0 taken 64193 times.
✗ Branch 1 not taken.
64193 if(index<0) index=MAXMIDIS-1;
8112
8113
1/2
✓ Branch 0 taken 64193 times.
✗ Branch 1 not taken.
64193 if(index>=MAXMIDIS) index=0;
8114
8115 // do nothing if it's already playing
8116
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 64182 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
64193 if(index==currmidi && midi_pos>=0)
8117 {
8118 11 return;
8119 }
8120
8121 64182 jukebox(index,tunes[index].loop);
8122 64193 }
8123
8124 160 void play_DmapMusic()
8125 {
8126
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 60 times.
160 if (is_headless())
8127 100 return;
8128
8129 static char tfile[2048];
8130 static int32_t ttrack=0;
8131 60 bool domidi=false;
8132
8133 60 int32_t fadeoutframes = 0;
8134
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if (zcmusic != NULL)
8135 fadeoutframes = zcmusic->fadeoutframes;
8136
8137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(DMaps[currdmap].tmusic[0]!=0)
8138 {
8139 if(zcmusic==NULL ||
8140 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8141 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8142 {
8143 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8144 {
8145 if (play_enh_music_crossfade(DMaps[currdmap].tmusic, qstpath, DMaps[currdmap].tmusictrack, get_emusic_volume(), DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8146 {
8147 if (zcmusic != NULL)
8148 {
8149 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8150 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8151 }
8152 }
8153 }
8154 else
8155 {
8156 if (zcmusic != NULL)
8157 {
8158 zcmusic_stop(zcmusic);
8159 zcmusic_unload_file(zcmusic);
8160 zcmusic = NULL;
8161 zcmixer->newtrack = NULL;
8162 }
8163
8164 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8165 zcmixer->newtrack = zcmusic;
8166
8167 if (zcmusic != NULL)
8168 {
8169 zc_stop_midi();
8170 strcpy(tfile, DMaps[currdmap].tmusic);
8171 zcmusic_play(zcmusic, emusic_volume);
8172 int32_t temptracks = 0;
8173 temptracks = zcmusic_get_tracks(zcmusic);
8174 temptracks = (temptracks < 2) ? 1 : temptracks;
8175 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8176 zcmusic_change_track(zcmusic, ttrack);
8177 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8178 }
8179 else
8180 {
8181 tfile[0] = 0;
8182 domidi = true;
8183 }
8184 }
8185 }
8186 }
8187 else
8188 {
8189
3/8
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
60 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8190 {
8191 play_enh_music_crossfade(NULL, qstpath, DMaps[currdmap].tmusictrack, get_emusic_volume(), DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8192 }
8193 else
8194 {
8195 60 domidi = true;
8196 }
8197 }
8198
8199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(domidi)
8200 {
8201 60 int32_t m=DMaps[currdmap].midi;
8202
8203
2/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60 switch(m)
8204 {
8205 case 1:
8206 37 jukebox(ZC_MIDI_OVERWORLD);
8207 37 break;
8208
8209 case 2:
8210 jukebox(ZC_MIDI_DUNGEON);
8211 break;
8212
8213 case 3:
8214 jukebox(ZC_MIDI_LEVEL9);
8215 break;
8216
8217 default:
8218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8219 jukebox(m+MIDIOFFSET_DMAP);
8220 else
8221 23 music_stop();
8222 23 }
8223 60 }
8224 160 }
8225
8226 34927 void playLevelMusic()
8227 {
8228
2/2
✓ Branch 0 taken 34867 times.
✓ Branch 1 taken 60 times.
34927 if (is_headless())
8229 34867 return;
8230
8231 60 int32_t m=tmpscr->screen_midi;
8232
8233
1/6
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
60 switch(m)
8234 {
8235 case -2:
8236 music_stop();
8237 break;
8238
8239 case -1:
8240 60 play_DmapMusic();
8241 60 break;
8242
8243 case 1:
8244 jukebox(ZC_MIDI_OVERWORLD);
8245 break;
8246
8247 case 2:
8248 jukebox(ZC_MIDI_DUNGEON);
8249 break;
8250
8251 case 3:
8252 jukebox(ZC_MIDI_LEVEL9);
8253 break;
8254
8255 default:
8256 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8257 jukebox(m+MIDIOFFSET_MAPSCR);
8258 else
8259 music_stop();
8260 }
8261 34927 }
8262
8263 4303 void master_volume(int32_t dv,int32_t mv)
8264 {
8265
7/8
✓ Branch 0 taken 2007 times.
✓ Branch 1 taken 2296 times.
✓ Branch 2 taken 1967 times.
✓ Branch 3 taken 329 times.
✓ Branch 4 taken 2296 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1967 times.
✓ Branch 7 taken 329 times.
4303 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8266
8267
7/8
✓ Branch 0 taken 2004 times.
✓ Branch 1 taken 2299 times.
✓ Branch 2 taken 1998 times.
✓ Branch 3 taken 301 times.
✓ Branch 4 taken 2299 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1998 times.
✓ Branch 7 taken 301 times.
4303 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8268
8269
5/6
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 4277 times.
✓ Branch 2 taken 4303 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✓ Branch 5 taken 4277 times.
4303 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8270 4303 int32_t temp_vol = midi_volume;
8271
2/2
✓ Branch 0 taken 4040 times.
✓ Branch 1 taken 263 times.
4303 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8272 263 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8273 4303 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8274 4303 }
8275
8276 /*****************/
8277 /***** SFX *****/
8278 /*****************/
8279
8280 // array of voices, one for each sfx sample in the data file
8281 // 0+ = voice #
8282 // -1 = voice not allocated
8283 263 void Z_init_sound()
8284 {
8285
2/2
✓ Branch 0 taken 67328 times.
✓ Branch 1 taken 263 times.
67591 for(int32_t i=0; i<WAV_COUNT; i++)
8286 67328 sfx_voice[i]=-1;
8287
8288 263 const char* midis[ZC_MIDI_COUNT] = {
8289 "assets/dungeon.mid",
8290 "assets/ending.mid",
8291 "assets/gameover.mid",
8292 "assets/level9.mid",
8293 "assets/overworld.mid",
8294 "assets/title.mid",
8295 "assets/triforce.mid",
8296 };
8297
2/2
✓ Branch 0 taken 1841 times.
✓ Branch 1 taken 263 times.
2104 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8298 {
8299 1841 tunes[i].data = load_midi(midis[i]);
8300
1/2
✓ Branch 0 taken 1841 times.
✗ Branch 1 not taken.
1841 if (!tunes[i].data)
8301 Z_error_fatal("Missing required file %s\n", midis[i]);
8302 1841 }
8303
8304
2/2
✓ Branch 0 taken 66276 times.
✓ Branch 1 taken 263 times.
66539 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8305 66276 tunes[ZC_MIDI_COUNT+j].data=NULL;
8306
8307 263 master_volume(digi_volume,midi_volume);
8308 263 }
8309
8310 // returns number of voices currently allocated
8311 int32_t sfx_count()
8312 {
8313 int32_t c=0;
8314
8315 for(int32_t i=0; i<WAV_COUNT; i++)
8316 if(sfx_voice[i]!=-1)
8317 ++c;
8318
8319 return c;
8320 }
8321
8322 // clean up finished samples
8323 18110195 void sfx_cleanup()
8324 {
8325
2/2
✓ Branch 0 taken 4636209920 times.
✓ Branch 1 taken 18110195 times.
4654320115 for(int32_t i=0; i<WAV_COUNT; i++)
8326
3/4
✓ Branch 0 taken 1257112 times.
✓ Branch 1 taken 4634952808 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1257112 times.
4637467032 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8327 {
8328 1257112 deallocate_voice(sfx_voice[i]);
8329 1257112 sfx_voice[i]=-1;
8330 1257112 }
8331 18110195 }
8332
8333 1257249 SAMPLE* sfx_get_sample(int32_t index)
8334 {
8335 // check index
8336
2/4
✓ Branch 0 taken 1257249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1257249 times.
1257249 if (index<=0 || index>=WAV_COUNT)
8337 return nullptr;
8338
8339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1257249 times.
1257249 if (sfxdat)
8340 {
8341 if (index<Z35)
8342 {
8343 return (SAMPLE*)sfxdata[index].dat;
8344 }
8345 else
8346 {
8347 return (SAMPLE*)sfxdata[Z35].dat;
8348 }
8349 }
8350 else
8351 {
8352 1257249 return &customsfxdata[index];
8353 }
8354
8355 return nullptr;
8356 1257249 }
8357
8358 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8359 // if a voice is already allocated (and/or playing), then it just returns true
8360 // Returns true: voice is allocated
8361 // false: unsuccessful
8362 1847447 bool sfx_init(int32_t index)
8363 {
8364 // check index
8365
3/4
✓ Branch 0 taken 1387859 times.
✓ Branch 1 taken 459588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1387859 times.
1847447 if(index<=0 || index>=WAV_COUNT)
8366 459588 return false;
8367
8368
2/2
✓ Branch 0 taken 130656 times.
✓ Branch 1 taken 1257203 times.
1387859 if (sfx_voice[index] == -1)
8369 {
8370 1257203 SAMPLE* sample = sfx_get_sample(index);
8371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1257203 times.
1257203 if (!sample)
8372 return false;
8373
8374 1257203 sfx_voice[index] = allocate_voice(sample);
8375 1257203 }
8376
8377 1387859 return sfx_voice[index] != -1;
8378 1847447 }
8379
8380 793 int32_t sfx_get_default_freq(int32_t index)
8381 {
8382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 793 times.
793 if (sfxdat)
8383 {
8384 if (index < Z35)
8385 {
8386 return ((SAMPLE*)sfxdata[index].dat)->freq;
8387 }
8388 else
8389 {
8390 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8391 }
8392 }
8393 else
8394 {
8395 793 return customsfxdata[index].freq;
8396 }
8397 793 }
8398
8399 int32_t sfx_get_length(int32_t index)
8400 {
8401 if (sfxdat)
8402 {
8403 if (index < Z35)
8404 {
8405 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8406 }
8407 else
8408 {
8409 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8410 }
8411 }
8412 else
8413 {
8414 return int32_t(customsfxdata[index].len);
8415 }
8416 }
8417
8418 // plays an sfx sample
8419 1847314 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8420 {
8421
2/2
✓ Branch 0 taken 1387789 times.
✓ Branch 1 taken 459525 times.
1847314 if(!sfx_init(index))
8422 459525 return;
8423
2/2
✓ Branch 0 taken 1386996 times.
✓ Branch 1 taken 793 times.
1387789 if (!is_headless())
8424 {
8425 793 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8426 793 voice_set_pan(sfx_voice[index], pan);
8427
8428 // Only used by ZScript currently
8429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 793 times.
793 if (freq <= -1)
8430 {
8431 793 freq = sfx_get_default_freq(index);
8432 793 }
8433 793 voice_set_frequency(sfx_voice[index], freq);
8434
8435 // Only used by ZScript currently
8436 793 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8437
2/4
✓ Branch 0 taken 793 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793 times.
✗ Branch 3 not taken.
793 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8438 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8439 793 voice_set_volume(sfx_voice[index], temp_volume);
8440
8441 793 int32_t pos = voice_get_position(sfx_voice[index]);
8442
8443
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 278 times.
793 if (restart) voice_set_position(sfx_voice[index], 0);
8444
8445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 793 times.
793 if (pos <= 0)
8446 793 voice_start(sfx_voice[index]);
8447 793 }
8448
8449
4/4
✓ Branch 0 taken 856070 times.
✓ Branch 1 taken 531719 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 856055 times.
1387789 if (restart && replay_is_debug())
8450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 856055 times.
856055 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8451 1847314 }
8452
8453 // true if sfx is allocated
8454 199119 bool sfx_allocated(int32_t index)
8455 {
8456
3/4
✓ Branch 0 taken 33965 times.
✓ Branch 1 taken 165154 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33965 times.
199119 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8457 }
8458
8459 // start it (in loop mode) if it's not already playing,
8460 // otherwise adjust it to play in loop mode -DD
8461 116961 void cont_sfx(int32_t index)
8462 {
8463
2/2
✓ Branch 0 taken 116828 times.
✓ Branch 1 taken 133 times.
116961 if (is_headless())
8464 116828 return;
8465
8466
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 63 times.
133 if(!sfx_init(index))
8467 {
8468 63 return;
8469 }
8470
8471
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if(voice_get_position(sfx_voice[index])<=0)
8472 {
8473 70 voice_set_position(sfx_voice[index],0);
8474 70 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8475 70 voice_set_volume(sfx_voice[index], sfx_volume);
8476 70 voice_start(sfx_voice[index]);
8477 70 }
8478 else
8479 {
8480 adjust_sfx(index, 128, true);
8481 }
8482 116961 }
8483
8484 // adjust parameters while playing
8485 6765 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8486 {
8487
4/6
✓ Branch 0 taken 4481 times.
✓ Branch 1 taken 2284 times.
✓ Branch 2 taken 4481 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4481 times.
6765 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8488 6765 return;
8489
8490 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8491 voice_set_pan(sfx_voice[index],pan);
8492 6765 }
8493
8494 // pauses a voice
8495 3223 void pause_sfx(int32_t index)
8496 {
8497
3/6
✓ Branch 0 taken 3223 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3223 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3223 times.
3223 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8498 voice_stop(sfx_voice[index]);
8499 3223 }
8500
8501 // resumes a voice
8502 1360 void resume_sfx(int32_t index)
8503 {
8504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1360 times.
1360 if (is_headless())
8505 1360 return;
8506
8507 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8508 voice_start(sfx_voice[index]);
8509 1360 }
8510
8511 // pauses all active voices
8512 1078 void pause_all_sfx()
8513 {
8514
2/2
✓ Branch 0 taken 275968 times.
✓ Branch 1 taken 1078 times.
277046 for(int32_t i=0; i<WAV_COUNT; i++)
8515
2/2
✓ Branch 0 taken 275966 times.
✓ Branch 1 taken 2 times.
275970 if(sfx_voice[i]!=-1)
8516 2 voice_stop(sfx_voice[i]);
8517 1078 }
8518
8519 // resumes all paused voices
8520 1017 void resume_all_sfx()
8521 {
8522
2/2
✓ Branch 0 taken 260352 times.
✓ Branch 1 taken 1017 times.
261369 for(int32_t i=0; i<WAV_COUNT; i++)
8523
1/2
✓ Branch 0 taken 260352 times.
✗ Branch 1 not taken.
260352 if(sfx_voice[i]!=-1)
8524 voice_start(sfx_voice[i]);
8525 1017 }
8526
8527 // stops an sfx and deallocates the voice
8528 14485863 void stop_sfx(int32_t index)
8529 {
8530
3/4
✓ Branch 0 taken 14238836 times.
✓ Branch 1 taken 247027 times.
✓ Branch 2 taken 14238836 times.
✗ Branch 3 not taken.
14485863 if(index<=0 || index>=WAV_COUNT)
8531 247027 return;
8532
8533
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 14238803 times.
14238836 if(sfx_voice[index]!=-1)
8534 {
8535 33 deallocate_voice(sfx_voice[index]);
8536 33 sfx_voice[index]=-1;
8537 33 }
8538 14485863 }
8539
8540 // Stops SFX played by Hero's item of the given family
8541 130619 void stop_item_sfx(int32_t family)
8542 {
8543 130619 int32_t id=current_item_id(family);
8544
8545
2/2
✓ Branch 0 taken 129519 times.
✓ Branch 1 taken 1100 times.
130619 if(id<0)
8546 129519 return;
8547
8548 1100 stop_sfx(itemsbuf[id].usesound);
8549 130619 }
8550
8551 8002 void kill_sfx()
8552 {
8553
2/2
✓ Branch 0 taken 2048512 times.
✓ Branch 1 taken 8002 times.
2056514 for(int32_t i=0; i<WAV_COUNT; i++)
8554
2/2
✓ Branch 0 taken 2048456 times.
✓ Branch 1 taken 56 times.
2048568 if(sfx_voice[i]!=-1)
8555 {
8556 56 deallocate_voice(sfx_voice[i]);
8557 56 sfx_voice[i]=-1;
8558 56 }
8559 8002 }
8560
8561 1172503 int32_t pan(int32_t x)
8562 {
8563
1/4
✓ Branch 0 taken 1172503 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1172503 switch(pan_style)
8564 {
8565 case 0:
8566 return 128;
8567
8568 case 1:
8569 1172503 return vbound((x>>1)+68,0,255);
8570
8571 case 2:
8572 return vbound(((x*3)>>2)+36,0,255);
8573 }
8574
8575 return vbound(x,0,255);
8576 1172503 }
8577
8578 /*******************************/
8579 /******* Input Handlers ********/
8580 /*******************************/
8581
8582 49877230 bool joybtn(int32_t b)
8583 {
8584
1/2
✓ Branch 0 taken 49877230 times.
✗ Branch 1 not taken.
49877230 if(b == 0)
8585 return false;
8586
1/2
✓ Branch 0 taken 49877230 times.
✗ Branch 1 not taken.
49877230 if (b-1 >= joy[joystick_index].num_buttons)
8587 49877230 return false;
8588
8589 return joy[joystick_index].button[b-1].b !=0;
8590 49877230 }
8591
8592 bool joystick(int32_t s)
8593 {
8594 if(s < 0)
8595 return false;
8596 if (s >= joy[joystick_index].num_sticks)
8597 return false;
8598
8599 for (int i = 0; i < joy[joystick_index].stick[s].num_axis; i++)
8600 {
8601 if (joy[joystick_index].stick[s].axis[i].d1 || joy[joystick_index].stick[s].axis[i].d2)
8602 return true;
8603 }
8604 return false;
8605 }
8606
8607 const char* joybtn_name(int32_t b)
8608 {
8609 if (b <= 0 || b > joy[joystick_index].num_buttons)
8610 return "";
8611
8612 return joy[joystick_index].button[b-1].name;
8613 }
8614
8615 const char* joystick_name(int32_t s)
8616 {
8617 if (s < 0 || s >= joy[joystick_index].num_sticks)
8618 return "";
8619
8620 return joy[joystick_index].stick[s].name;
8621 }
8622
8623 int32_t button_pressed()
8624 {
8625 if (joystick_index >= MAX_JOYSTICKS)
8626 return 0;
8627
8628 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8629 {
8630 if(joybtn(i))
8631 return i;
8632 }
8633
8634 return 0;
8635 }
8636
8637 int32_t next_press_key();
8638
8639 int32_t next_joy_input(bool buttons)
8640 {
8641 clear_keybuf();
8642
8643 //first, we need to wait until they're pressing no buttons
8644 for(;;)
8645 {
8646 if(keypressed())
8647 {
8648 switch(readkey()>>8)
8649 {
8650 case KEY_ESC:
8651 return -1;
8652
8653 case KEY_SPACE:
8654 return 0;
8655 }
8656 }
8657
8658 poll_joystick();
8659 bool done = true;
8660
8661 if (buttons)
8662 {
8663 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8664 {
8665 if(joybtn(i)) done = false;
8666 }
8667 }
8668 else
8669 {
8670 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8671 {
8672 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8673 return -2;
8674 }
8675 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8676 {
8677 if(joystick(i)) done = false;
8678 }
8679 }
8680
8681 if(done) break;
8682 rest(1);
8683 }
8684
8685 //now, we need to wait for them to press any button
8686 for(;;)
8687 {
8688 if(keypressed())
8689 {
8690 switch(readkey()>>8)
8691 {
8692 case KEY_ESC:
8693 return -1;
8694
8695 case KEY_SPACE:
8696 return 0;
8697 }
8698 }
8699
8700 poll_joystick();
8701
8702 if (buttons)
8703 {
8704 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8705 {
8706 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8707 return -2;
8708 }
8709 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8710 {
8711 if(joybtn(i))
8712 return i;
8713 }
8714 }
8715 else
8716 {
8717 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8718 {
8719 if(joystick(i))
8720 return i;
8721 }
8722 }
8723 rest(1);
8724 }
8725 }
8726
8727 7415325 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8728 {
8729
2/2
✓ Branch 0 taken 7389040 times.
✓ Branch 1 taken 26285 times.
7415325 bool ret = btn && !flag;
8730 7415325 flag = rawbtn;
8731
8732 7415325 return ret;
8733 }
8734 373399710 static bool rButton(bool &btn, bool &flag)
8735 {
8736
2/2
✓ Branch 0 taken 359638407 times.
✓ Branch 1 taken 13761303 times.
373399710 bool ret = btn && !flag;
8737 373399710 flag = btn;
8738
8739 373399710 return ret;
8740 }
8741 4577206 static bool rButtonPeek(bool btn, bool flag)
8742 {
8743
2/2
✓ Branch 0 taken 4236933 times.
✓ Branch 1 taken 340273 times.
4577206 if(!btn)
8744 {
8745 4236933 return false;
8746 }
8747
2/2
✓ Branch 0 taken 33326 times.
✓ Branch 1 taken 306947 times.
340273 else if(!flag)
8748 {
8749 33326 return true;
8750 }
8751
8752 306947 return false;
8753 4577206 }
8754
8755 // Updated only by keyboard/gamepad.
8756 // If in replay mode, this is set directly by the replay system.
8757 // This should never be read from directly - use control_state instead.
8758 bool raw_control_state[ZC_CONTROL_STATES];
8759
8760 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8761 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8762 // lasts until the next call to load_control_state.
8763 bool control_state[ZC_CONTROL_STATES];
8764 bool disable_control[ZC_CONTROL_STATES];
8765 bool drunk_toggle_state[11];
8766 bool disabledKeys[127];
8767 bool KeyInput[127];
8768 bool KeyPress[127];
8769
8770 bool key_current_frame[127];
8771 bool key_previous_frame[127];
8772
8773 static bool key_system[127];
8774 static bool key_system_previous[127];
8775 static bool key_system_press[127];
8776
8777 bool button_press[ZC_CONTROL_STATES];
8778 bool button_hold[ZC_CONTROL_STATES];
8779
8780 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8781 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8782 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8783 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8784 #define STICK_PRECISION 56 //define your own sensitivity
8785
8786 15501834 void load_control_state()
8787 {
8788 15501834 load_control_called_this_frame = true;
8789
8790
2/2
✓ Branch 0 taken 12372202 times.
✓ Branch 1 taken 3129632 times.
15501834 if (replay_version_check(8, 11))
8791 {
8792
2/2
✓ Branch 0 taken 56333376 times.
✓ Branch 1 taken 3129632 times.
59463008 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8793 56333376 down_control_states[i] = raw_control_state[i];
8794 3129632 }
8795
8796
2/2
✓ Branch 0 taken 15501813 times.
✓ Branch 1 taken 21 times.
15501834 if (!replay_is_replaying())
8797 {
8798
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8799
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8800
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8801
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8812
8813
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(num_joysticks != 0)
8814 {
8815 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8816 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8817 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8818 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8819 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8820 }
8821 else
8822 {
8823 21 raw_control_state[14] = false;
8824 21 raw_control_state[15] = false;
8825 21 raw_control_state[16] = false;
8826 21 raw_control_state[17] = false;
8827 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8828 }
8829 21 }
8830
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 15501829 times.
15501834 if (replay_is_active())
8831 {
8832
2/2
✓ Branch 0 taken 1211700 times.
✓ Branch 1 taken 14290129 times.
15501829 if (replay_get_version() < 3)
8833 1211700 replay_poll();
8834
4/4
✓ Branch 0 taken 14290108 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 12528114 times.
✓ Branch 3 taken 1761994 times.
14290129 else if (replay_is_replaying() && replay_get_version() < 6)
8835 1761994 replay_peek_input();
8836
4/4
✓ Branch 0 taken 12528114 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 9398482 times.
✓ Branch 3 taken 3129632 times.
12528135 else if (replay_is_replaying() && replay_version_check(8, 11))
8837 3129632 replay_peek_input();
8838
2/2
✓ Branch 0 taken 14235317 times.
✓ Branch 1 taken 1266512 times.
15501829 if (replay_get_version() == 8)
8839 1266512 update_keys();
8840 15501829 }
8841
8842 // Some test replay files were made before a serious input bug was fixed, so instead
8843 // of re-doing them or tossing them out, just check for that zplay version.
8844
3/4
✓ Branch 0 taken 15501824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 15379924 times.
15501834 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8845
2/2
✓ Branch 0 taken 279032832 times.
✓ Branch 1 taken 15501824 times.
294534656 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8846 {
8847 279032832 control_state[i] = raw_control_state[i];
8848
4/4
✓ Branch 0 taken 53035164 times.
✓ Branch 1 taken 225997668 times.
✓ Branch 2 taken 2612094 times.
✓ Branch 3 taken 50423070 times.
279032832 if (botched_input && !control_state[i])
8849 50423070 down_control_states[i] = false;
8850 279032832 }
8851 15501824 bool did_bad_cutscene_btn = false;
8852
2/2
✓ Branch 0 taken 15501824 times.
✓ Branch 1 taken 279032832 times.
294534656 for(int q = 0; q < 18; ++q)
8853
4/4
✓ Branch 0 taken 13195184 times.
✓ Branch 1 taken 265837648 times.
✓ Branch 2 taken 13192867 times.
✓ Branch 3 taken 2317 times.
279035149 if(control_state[q] && !active_cutscene.can_button(q))
8854 {
8855 2317 control_state[q] = false;
8856 2317 did_bad_cutscene_btn = true;
8857 2317 }
8858
2/2
✓ Branch 0 taken 15500164 times.
✓ Branch 1 taken 1660 times.
15501824 if(did_bad_cutscene_btn)
8859 1660 active_cutscene.error();
8860
8861 15501824 button_press[0]=rButton(control_state[0],button_hold[0]);
8862 15501824 button_press[1]=rButton(control_state[1],button_hold[1]);
8863 15501824 button_press[2]=rButton(control_state[2],button_hold[2]);
8864 15501824 button_press[3]=rButton(control_state[3],button_hold[3]);
8865 15501824 button_press[4]=rButton(control_state[4],button_hold[4]);
8866 15501824 button_press[5]=rButton(control_state[5],button_hold[5]);
8867 15501824 button_press[6]=rButton(control_state[6],button_hold[6]);
8868 15501824 button_press[7]=rButton(control_state[7],button_hold[7]);
8869 15501824 button_press[8]=rButton(control_state[8],button_hold[8]);
8870 15501824 button_press[9]=rButton(control_state[9],button_hold[9]);
8871 15501824 button_press[10]=rButton(control_state[10],button_hold[10]);
8872 15501824 button_press[11]=rButton(control_state[11],button_hold[11]);
8873 15501824 button_press[12]=rButton(control_state[12],button_hold[12]);
8874 15501824 button_press[13]=rButton(control_state[13],button_hold[13]);
8875 15501824 button_press[14]=rButton(control_state[14],button_hold[14]);
8876 15501824 button_press[15]=rButton(control_state[15],button_hold[15]);
8877 15501824 button_press[16]=rButton(control_state[16],button_hold[16]);
8878 15501824 button_press[17]=rButton(control_state[17],button_hold[17]);
8879 15501824 }
8880
8881 // Returns true if any game key is pressed. This is needed because keypressed()
8882 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8883 77832019 bool zc_key_pressed()
8884 //may also need to use zc_getrawkey
8885 {
8886
7/10
✓ Branch 0 taken 62855218 times.
✓ Branch 1 taken 14976801 times.
✓ Branch 2 taken 14976801 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14976801 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12262806 times.
✓ Branch 7 taken 12262806 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 4908847 times.
82740866 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8887
4/6
✓ Branch 0 taken 12262806 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12262806 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9336465 times.
✓ Branch 5 taken 9336465 times.
12262806 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8888
4/6
✓ Branch 0 taken 9336465 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9336465 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6186782 times.
✓ Branch 5 taken 6186782 times.
9336465 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8889
4/6
✓ Branch 0 taken 6186782 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6186782 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5312557 times.
✓ Branch 5 taken 5312557 times.
6186782 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8890
1/2
✓ Branch 0 taken 5312557 times.
✗ Branch 1 not taken.
5312557 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8891
3/4
✓ Branch 0 taken 5126821 times.
✓ Branch 1 taken 185736 times.
✓ Branch 2 taken 5126821 times.
✗ Branch 3 not taken.
5312557 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8892
3/4
✓ Branch 0 taken 4980693 times.
✓ Branch 1 taken 146128 times.
✓ Branch 2 taken 4980693 times.
✗ Branch 3 not taken.
5126821 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8893
3/4
✓ Branch 0 taken 4959823 times.
✓ Branch 1 taken 20870 times.
✓ Branch 2 taken 4959823 times.
✗ Branch 3 not taken.
4980693 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8894
3/4
✓ Branch 0 taken 4933464 times.
✓ Branch 1 taken 26359 times.
✓ Branch 2 taken 4933464 times.
✗ Branch 3 not taken.
4959823 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8895
3/4
✓ Branch 0 taken 4926179 times.
✓ Branch 1 taken 7285 times.
✓ Branch 2 taken 4926179 times.
✗ Branch 3 not taken.
4933464 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8896
3/4
✓ Branch 0 taken 4910789 times.
✓ Branch 1 taken 15390 times.
✓ Branch 2 taken 4910789 times.
✗ Branch 3 not taken.
4926179 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8897
3/4
✓ Branch 0 taken 4908941 times.
✓ Branch 1 taken 1848 times.
✓ Branch 2 taken 4908941 times.
✗ Branch 3 not taken.
4910789 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8898
3/4
✓ Branch 0 taken 4908906 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 4908906 times.
✗ Branch 3 not taken.
4908941 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8899
2/2
✓ Branch 0 taken 4908847 times.
✓ Branch 1 taken 59 times.
4908906 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8900 139120392 return true;
8901
8902 4908847 return false;
8903 18318803 }
8904
8905 294743332 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8906 {
8907 294743332 bool ret = false, drunkstate = false, rawret = false;;
8908 294743332 bool* flag = &down_control_states[btn];
8909
2/7
✓ Branch 0 taken 276405726 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 18337606 times.
294743332 switch(btn)
8910 {
8911 case btnF12:
8912 ret = zc_getkey(KEY_F12, ignoreDisable);
8913 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8914 eatEntirely = false;
8915 break;
8916 case btnF11:
8917 ret = zc_getkey(KEY_F11, ignoreDisable);
8918 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8919 eatEntirely = false;
8920 break;
8921 case btnF5:
8922 ret = zc_getkey(KEY_F5, ignoreDisable);
8923 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8924 eatEntirely = false;
8925 break;
8926 case btnQ:
8927 ret = zc_getkey(KEY_Q, ignoreDisable);
8928 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8929 eatEntirely = false;
8930 break;
8931 case btnI:
8932 ret = zc_getkey(KEY_I, ignoreDisable);
8933 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8934 eatEntirely = false;
8935 break;
8936 case btnM:
8937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18337606 times.
18337606 if(FFCore.kb_typing_mode) return false;
8938 18337606 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8939 18337606 eatEntirely = false;
8940 18337606 break;
8941 default: //control_state[] index
8942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276405726 times.
276405726 if(FFCore.kb_typing_mode) return false;
8943
6/6
✓ Branch 0 taken 275041496 times.
✓ Branch 1 taken 1364230 times.
✓ Branch 2 taken 16875342 times.
✓ Branch 3 taken 258166154 times.
✓ Branch 4 taken 16875189 times.
✓ Branch 5 taken 153 times.
276405726 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8944
2/2
✓ Branch 0 taken 15733278 times.
✓ Branch 1 taken 260672295 times.
276405573 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8945
4/4
✓ Branch 0 taken 245619837 times.
✓ Branch 1 taken 30785889 times.
✓ Branch 2 taken 5480 times.
✓ Branch 3 taken 30780409 times.
307191615 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8946 276405726 rawret = raw_control_state[btn];
8947 276405726 }
8948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294743332 times.
294743332 assert(flag);
8949
2/2
✓ Branch 0 taken 188383923 times.
✓ Branch 1 taken 106359409 times.
294743332 if(press)
8950 {
8951
2/2
✓ Branch 0 taken 4577206 times.
✓ Branch 1 taken 101782203 times.
106359409 if(peek)
8952 4577206 ret = rButtonPeek(ret, *flag);
8953
2/2
✓ Branch 0 taken 94366878 times.
✓ Branch 1 taken 7415325 times.
101782203 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
8954 7415325 else ret = rButton(ret, *flag, rawret);
8955 106359409 }
8956
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 294743332 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
294743332 if(eatEntirely && ret) control_state[btn] = false;
8957
4/4
✓ Branch 0 taken 220231060 times.
✓ Branch 1 taken 74512272 times.
✓ Branch 2 taken 220230979 times.
✓ Branch 3 taken 81 times.
294743332 if(drunk && drunkstate) ret = !ret;
8958 294743332 return ret;
8959 294743332 }
8960
8961 14809359 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8962 {
8963 14809359 byte ret = 0;
8964
2/2
✓ Branch 0 taken 10455066 times.
✓ Branch 1 taken 4354293 times.
14809359 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8965
2/2
✓ Branch 0 taken 14602130 times.
✓ Branch 1 taken 207229 times.
14809359 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8966
2/2
✓ Branch 0 taken 14602577 times.
✓ Branch 1 taken 206782 times.
14809359 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8967
2/2
✓ Branch 0 taken 14602577 times.
✓ Branch 1 taken 206782 times.
14809359 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8968
2/2
✓ Branch 0 taken 14602577 times.
✓ Branch 1 taken 206782 times.
14809359 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8969
2/2
✓ Branch 0 taken 14602577 times.
✓ Branch 1 taken 206782 times.
14809359 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8970
2/2
✓ Branch 0 taken 14602577 times.
✓ Branch 1 taken 206782 times.
14809359 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8971
2/2
✓ Branch 0 taken 14602462 times.
✓ Branch 1 taken 206897 times.
14809359 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8972 14809359 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8973 }
8974
8975 7515 byte checkIntBtnVal(byte intbtn, byte vals)
8976 {
8977 7515 return intbtn&vals;
8978 }
8979
8980 3709200 bool Up()
8981 {
8982 3709200 return getInput(btnUp);
8983 }
8984 727489 bool Down()
8985 {
8986 727489 return getInput(btnDown);
8987 }
8988 981338 bool Left()
8989 {
8990 981338 return getInput(btnLeft);
8991 }
8992 1042840 bool Right()
8993 {
8994 1042840 return getInput(btnRight);
8995 }
8996 532139 bool cAbtn()
8997 {
8998 532139 return getInput(btnA);
8999 }
9000 3306978 bool cBbtn()
9001 {
9002 3306978 return getInput(btnB);
9003 }
9004 bool cSbtn()
9005 {
9006 return getInput(btnS);
9007 }
9008 208608 bool cLbtn()
9009 {
9010 208608 return getInput(btnL);
9011 }
9012 208608 bool cRbtn()
9013 {
9014 208608 return getInput(btnR);
9015 }
9016 bool cPbtn()
9017 {
9018 return getInput(btnP);
9019 }
9020 bool cEx1btn()
9021 {
9022 return getInput(btnEx1);
9023 }
9024 bool cEx2btn()
9025 {
9026 return getInput(btnEx2);
9027 }
9028 bool cEx3btn()
9029 {
9030 return getInput(btnEx3);
9031 }
9032 bool cEx4btn()
9033 {
9034 return getInput(btnEx4);
9035 }
9036 bool AxisUp()
9037 {
9038 return getInput(btnAxisUp);
9039 }
9040 bool AxisDown()
9041 {
9042 return getInput(btnAxisDown);
9043 }
9044 bool AxisLeft()
9045 {
9046 return getInput(btnAxisLeft);
9047 }
9048 bool AxisRight()
9049 {
9050 return getInput(btnAxisRight);
9051 }
9052
9053 bool cMbtn()
9054 {
9055 return getInput(btnM);
9056 }
9057 bool cF12()
9058 {
9059 return getInput(btnF12);
9060 }
9061 bool cF11()
9062 {
9063 return getInput(btnF11);
9064 }
9065 bool cF5()
9066 {
9067 return getInput(btnF5);
9068 }
9069 bool cQ()
9070 {
9071 return getInput(btnQ);
9072 }
9073 bool cI()
9074 {
9075 return getInput(btnI);
9076 }
9077
9078 208304 bool rUp()
9079 {
9080 208304 return getInput(btnUp, true);
9081 }
9082 208096 bool rDown()
9083 {
9084 208096 return getInput(btnDown, true);
9085 }
9086 207900 bool rLeft()
9087 {
9088 207900 return getInput(btnLeft, true);
9089 }
9090 207171 bool rRight()
9091 {
9092 207171 return getInput(btnRight, true);
9093 }
9094 6570 bool rAbtn()
9095 {
9096 6570 return getInput(btnA, true);
9097 }
9098 4619 bool rBbtn()
9099 {
9100 4619 return getInput(btnB, true);
9101 }
9102 14372141 bool rSbtn()
9103 {
9104 14372141 return getInput(btnS, true);
9105 }
9106 18318803 bool rMbtn()
9107 {
9108 18318803 return getInput(btnM, true);
9109 }
9110 185250 bool rLbtn()
9111 {
9112 185250 return getInput(btnL, true);
9113 }
9114 185245 bool rRbtn()
9115 {
9116 185245 return getInput(btnR, true);
9117 }
9118 14372873 bool rPbtn()
9119 {
9120 14372873 return getInput(btnP, true);
9121 }
9122 bool rEx1btn()
9123 {
9124 return getInput(btnEx1, true);
9125 }
9126 bool rEx2btn()
9127 {
9128 return getInput(btnEx2, true);
9129 }
9130 195896 bool rEx3btn()
9131 {
9132 195896 return getInput(btnEx3, true);
9133 }
9134 195896 bool rEx4btn()
9135 {
9136 195896 return getInput(btnEx4, true);
9137 }
9138 bool rAxisUp()
9139 {
9140 return getInput(btnAxisUp, true);
9141 }
9142 bool rAxisDown()
9143 {
9144 return getInput(btnAxisDown, true);
9145 }
9146 bool rAxisLeft()
9147 {
9148 return getInput(btnAxisLeft, true);
9149 }
9150 bool rAxisRight()
9151 {
9152 return getInput(btnAxisRight, true);
9153 }
9154
9155 bool rF11()
9156 {
9157 return getInput(btnF11, true);
9158 }
9159 bool rQ()
9160 {
9161 return getInput(btnQ, true);
9162 }
9163 bool rI()
9164 {
9165 return getInput(btnI, true);
9166 }
9167
9168 36599881 bool DrunkUp()
9169 {
9170 36599881 return getInput(btnUp, false, true);
9171 }
9172 33401500 bool DrunkDown()
9173 {
9174 33401500 return getInput(btnDown, false, true);
9175 }
9176 19587217 bool DrunkLeft()
9177 {
9178 19587217 return getInput(btnLeft, false, true);
9179 }
9180 16665238 bool DrunkRight()
9181 {
9182 16665238 return getInput(btnRight, false, true);
9183 }
9184 15776028 bool DrunkcAbtn()
9185 {
9186 15776028 return getInput(btnA, false, true);
9187 }
9188 15217548 bool DrunkcBbtn()
9189 {
9190 15217548 return getInput(btnB, false, true);
9191 }
9192 14164082 bool DrunkcEx1btn()
9193 {
9194 14164082 return getInput(btnEx1, false, true);
9195 }
9196 14162714 bool DrunkcEx2btn()
9197 {
9198 14162714 return getInput(btnEx2, false, true);
9199 }
9200 bool DrunkcSbtn()
9201 {
9202 return getInput(btnS, false, true);
9203 }
9204 bool DrunkcMbtn()
9205 {
9206 return getInput(btnM, false, true);
9207 }
9208 bool DrunkcLbtn()
9209 {
9210 return getInput(btnL, false, true);
9211 }
9212 bool DrunkcRbtn()
9213 {
9214 return getInput(btnR, false, true);
9215 }
9216 bool DrunkcPbtn()
9217 {
9218 return getInput(btnP, false, true);
9219 }
9220
9221 bool DrunkrUp()
9222 {
9223 return getInput(btnUp, true, true);
9224 }
9225 bool DrunkrDown()
9226 {
9227 return getInput(btnDown, true, true);
9228 }
9229 bool DrunkrLeft()
9230 {
9231 return getInput(btnLeft, true, true);
9232 }
9233 bool DrunkrRight()
9234 {
9235 return getInput(btnRight, true, true);
9236 }
9237 11837226 bool DrunkrAbtn()
9238 {
9239 11837226 return getInput(btnA, true, true);
9240 }
9241 11865813 bool DrunkrBbtn()
9242 {
9243 11865813 return getInput(btnB, true, true);
9244 }
9245 502081 bool DrunkrEx1btn()
9246 {
9247 502081 return getInput(btnEx1, true, true);
9248 }
9249 501902 bool DrunkrEx2btn()
9250 {
9251 501902 return getInput(btnEx2, true, true);
9252 }
9253 bool DrunkrEx3btn()
9254 {
9255 return getInput(btnEx3, true, true);
9256 }
9257 bool DrunkrEx4btn()
9258 {
9259 return getInput(btnEx4, true, true);
9260 }
9261 bool DrunkrSbtn()
9262 {
9263 return getInput(btnS, true, true);
9264 }
9265 bool DrunkrMbtn()
9266 {
9267 return getInput(btnM, true, true);
9268 }
9269 12901783 bool DrunkrLbtn()
9270 {
9271 12901783 return getInput(btnL, true, true);
9272 }
9273 12896478 bool DrunkrRbtn()
9274 {
9275 12896478 return getInput(btnR, true, true);
9276 }
9277 bool DrunkrPbtn()
9278 {
9279 return getInput(btnP, true, true);
9280 }
9281
9282 18803 void eat_buttons()
9283 {
9284 18803 getInput(btnA, true, false, true);
9285 18803 getInput(btnB, true, false, true);
9286 18803 getInput(btnS, true, false, true);
9287 18803 getInput(btnM, true, false, true);
9288 18803 getInput(btnL, true, false, true);
9289 18803 getInput(btnR, true, false, true);
9290 18803 getInput(btnP, true, false, true);
9291 18803 getInput(btnEx1, true, false, true);
9292 18803 getInput(btnEx2, true, false, true);
9293 18803 getInput(btnEx3, true, false, true);
9294 18803 getInput(btnEx4, true, false, true);
9295 18803 }
9296
9297 // Is true for the _first frame_ of a key press.
9298 // But! it is possible that a script manually sets the value of KeyPress,
9299 // in which case it will be restored to the "true" value based on `key_current_frame`
9300 // and `key_previous_frame` on the next frame.
9301 61 bool zc_readkey(int32_t k, bool ignoreDisable)
9302 {
9303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(ignoreDisable) return KeyPress[k];
9304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 switch(k)
9305 {
9306 case KEY_F7:
9307 case KEY_F8:
9308 case KEY_F9:
9309 return KeyPress[k];
9310
9311 default:
9312
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 15 times.
61 return KeyPress[k] && !disabledKeys[k];
9313 }
9314 61 }
9315
9316 // Is true for _every frame_ a key is held down.
9317 // But! it is possible that a script manually sets the value of KeyInput,
9318 // in which case it will be restored to the "true" value based on `key_current_frame`
9319 // on the next frame.
9320 bool zc_getkey(int32_t k, bool ignoreDisable)
9321 {
9322 if(ignoreDisable) return KeyInput[k];
9323 switch(k)
9324 {
9325 case KEY_F7:
9326 case KEY_F8:
9327 case KEY_F9:
9328 return KeyInput[k];
9329
9330 default:
9331 return KeyInput[k] && !disabledKeys[k];
9332 }
9333 }
9334
9335 // Reads (and then clears) the current frame key state directly.
9336 // Scripts can also modify `key_current_frame`.
9337 933 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9338 {
9339
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 931 times.
933 if(zc_getrawkey(k, ignoreDisable))
9340 {
9341 2 _key[k]=key[k]=key_current_frame[k]=0;
9342 2 return true;
9343 }
9344 931 _key[k]=key[k]=key_current_frame[k]=0;
9345 931 return false;
9346 933 }
9347
9348 // Reads the current frame key state directly.
9349 // Scripts can also modify `key_current_frame`.
9350 124388663 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9351 {
9352
2/2
✓ Branch 0 taken 106069738 times.
✓ Branch 1 taken 18318925 times.
124388663 if(ignoreDisable) return key_current_frame[k];
9353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318925 times.
18318925 switch(k)
9354 {
9355 case KEY_F7:
9356 case KEY_F8:
9357 case KEY_F9:
9358 return key_current_frame[k];
9359
9360 default:
9361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318925 times.
18318925 return key_current_frame[k] && !disabledKeys[k];
9362 }
9363 124388663 }
9364
9365 // Only used for a handful of keys, like tilde and Function keys.
9366 // This state is never read within the game.
9367 // It exists so that all keyboard input still functions during replay,
9368 // without inadvertently doing things like toggling throttling if the player
9369 // presses ~
9370 18341245 bool zc_get_system_key(int32_t k)
9371 {
9372 18341245 return key_system[k];
9373 }
9374
9375 // True for the _first_ frame of a key press.
9376 164869227 bool zc_read_system_key(int32_t k)
9377 {
9378 164869227 return key_system_press[k];
9379 }
9380
9381 2326487981 bool is_system_key(int32_t k)
9382 {
9383
2/2
✓ Branch 0 taken 2161618754 times.
✓ Branch 1 taken 164869227 times.
2326487981 switch (k)
9384 {
9385 case KEY_BACKQUOTE:
9386 case KEY_CLOSEBRACE:
9387 case KEY_END:
9388 case KEY_HOME:
9389 case KEY_OPENBRACE:
9390 case KEY_PGDN:
9391 case KEY_PGUP:
9392 case KEY_TAB:
9393 case KEY_TILDE:
9394 164869227 return true;
9395 }
9396 2161618754 return is_Fkey(k);
9397 2326487981 }
9398
9399 18318803 void update_system_keys()
9400 {
9401
2/2
✓ Branch 0 taken 2326487981 times.
✓ Branch 1 taken 18318803 times.
2344806784 for (int32_t q = 0; q < 127; ++q)
9402 {
9403
2/2
✓ Branch 0 taken 384694863 times.
✓ Branch 1 taken 1941793118 times.
2326487981 if (!is_system_key(q))
9404 1941793118 continue;
9405
9406 384694863 key_system[q] = key[q];
9407
1/2
✓ Branch 0 taken 384694863 times.
✗ Branch 1 not taken.
384694863 key_system_press[q] = key_system[q] && !key_system_previous[q];
9408 384694863 key_system_previous[q] = key_system[q];
9409 384694863 }
9410 18318803 }
9411
9412 19585315 void update_keys()
9413 {
9414
2/2
✓ Branch 0 taken 2487335005 times.
✓ Branch 1 taken 19585315 times.
2506920320 for (int32_t q = 0; q < 127; ++q)
9415 {
9416 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9417
2/2
✓ Branch 0 taken 2487322305 times.
✓ Branch 1 taken 12700 times.
2487335005 if (!replay_is_replaying())
9418 12700 key_current_frame[q] = key[q];
9419
9420
2/2
✓ Branch 0 taken 2468237367 times.
✓ Branch 1 taken 19097638 times.
2487335005 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9421 2487335005 KeyInput[q] = key_current_frame[q];
9422 2487335005 key_previous_frame[q] = key_current_frame[q];
9423 2487335005 }
9424 19585315 }
9425
9426 bool zc_disablekey(int32_t k, bool val)
9427 {
9428 switch(k)
9429 {
9430 case KEY_F7:
9431 case KEY_F8:
9432 case KEY_F9:
9433 return false;
9434
9435 default:
9436 disabledKeys[k] = val;
9437 return true;
9438 }
9439 }
9440
9441 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9442 {
9443 timer=timer;
9444 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9445 }
9446